Set up precise heatmaps with Google Tag Manager
Precise heatmaps track every link click on your site, not just the ones GA4 records by default. This page shows you how to set that up in Google Tag Manager (GTM). You need GTM installed on your site and a GA4 Measurement ID.
Create the link-click trigger
Start with a trigger that captures every link interaction on your site.
- Go to the Triggers section
- Click New to create a trigger
- Choose Just Links as the trigger type
- Configure it to fire on All Link Clicks
Enable the required variables
Enable the built-in variables that the tag needs.
In the Variables section, under Configure, enable these Click variables:
- Click Classes
- Click ID
- Click URL
- Click Text
Create the GA4 event tag
Set up a GA4 event tag to send the click data.
- Create a new tag of type Google Analytics: GA4 Event
- Enter your Measurement ID
- Set Event Name to
link_click - Add these Event Parameters:
- link_classes:
{{Click Classes}} - link_id:
{{Click ID}} - link_url:
{{Click URL}} - link_text:
{{Click Text}}
- link_classes:
Separate links that share a destination
If several links point to the same URL, you can show a separate heatmap count for each identified link. Give those links unique, stable HTML id values:
<a href="/eikenhout" id="material-strip-eikenhout">Eikenhout</a>
The GTM tag already sends each link's ID as its link_id value, so no additional GTM variable is needed. Keep each ID stable across deploys. Changing an ID starts a new link's history. Links without an ID remain grouped by destination URL.
Connect the tag and trigger
Connect the new tag to the link-click trigger.
Enable precise heatmaps in Page Analytics
After you publish the GTM container:
- Open precise heatmap settings in Page Analytics
- Find your website
- Turn on Enable precise heatmaps
- Under Match clicks to links by, choose HTML ID if you added stable IDs. Otherwise, keep Destination URL selected.