Objective
To track link clicks on your website and send them to Google Analytics 4 (GA4) using Google Tag Manager (GTM). This includes tracking links to documents, external websites, or any clickable anchor elements (<a> tags).
Step 1: Enable Click Variables in GTM
- In Google Tag Manager, go to Variables
- Click “Configure” (top-right)
- Under the Clicks section, enable the following:
- Click ID
- Click Classes
- Click Text
- Click URL
- Click Element (optional)
Step 2: Create a Trigger for Link Clicks
Option A: Track All Link Clicks
- Go to Triggers → Click “New”
- Name the trigger: Link Click – All
- Trigger Configuration → Choose Just Links
- Check:
✅Wait for Tags (optional, but recommended for accuracy)
✅ Check Validation
5. Choose: All Link Clicks
6. Save
Option B: Track Specific Link Clicks (e.g. external links, downloads)
Use conditions like:
- Click URL contains https://externaldomain.com
- Click URL ends with .pdf
- Click URL does not contain your domain name (for outbound links)
Option C: Track Internal Link Clicks
Use conditions like:
- Click URL contains internaldomain.com
Step 3: Create the GA4 Event Tag
- Go to Tags → Click New
- Name it: GA4 – link_click
- Tag Configuration → Select Google Analytics: GA4 Event
- Under Configuration Tag, select your existing GA4 config
- Event Name: link_click
- Add Event Parameters (optional but useful for analysis):
| Parameter Name | Value |
| link_url | {{Click URL}} |
| link_text | {{Click Text}} |
| page_path | {{Page Path}} |
7. Click Triggering → Choose the trigger created in Step 2
8. Save the tag
Step 4: Preview and Test
- Click Preview in GTM
- Enter your website URL and click Connect
- Click one of the tracked links (PDF, external site, etc.)
- In the Tag Assistant window:
- Confirm the link click trigger fires
- Confirm your GA4 tag fires
- See values like Click URL and Click Text
5. Optional: Check GA4 Realtime to confirm the event appears
Step 5: Publish
Once verified:
- Click Submit → Publish in GTM
- Name the version: GA4 – Link Click Tracking
Note
- Want to track outbound links only? Use a trigger condition like:
Click URL does not contain saigon.digital
- Want to track downloads only? Use a trigger like:
Click URL ends with .pdf
- Use Lookup Table Variables to assign labels to link types or destinations