Sunday, 24 May 2020

Tracking clicks on an image link via Google Tag Manager

Consider the following image link (link in the form of an image):

<a id=”checklist2″ href=”http://www.weplan.com/Worksheets/worksheets.pdf” ><img src=”http://www.book2web.com/images/download-button-blue-300×133.png” /></a>


In order to track clicks on an image link, follow the steps below:

Step-1: Navigate to the web page (in Google Chrome browser) which contains the image link you want to track via GTM

Step-2: Note down the URL of the web page where the image link is embedded.

Step-3: Note down the ‘ID’ attribute of the image link through Google developer console (as explained earlier). If the ‘ID’ attribute is missing, then ask your developer to add one.

Step-4: Navigate to Google Tag Manager and create a new trigger with following similar configurations:
Trigger Name: Check for click on the image download link
Trigger Type: Click – Just links 
Check Validation
1. Enable this trigger when: Page URL equals <<enter the URL of the page where the image link you want to track is embedded>> 
2. This trigger fires on: Click ID equals <<enter the ID of your <a> element>>
If you want to use the ‘id’ attribute of the image tag instead of the ‘id’ attribute of the <a> tag in order to identify your image link:
<a id=”checklist2″ href=”http://www.weplan.com/Worksheets/worksheets.pdf” ><img src=”http://www.book2web.com/images/download-button-blue-300×133.png” /></a> 
<a href=”http://www.weplan.com/Worksheets/worksheets.pdf” ><img id=”checklist2″ src=”http://www.book2web.com/images/downloadbutton-blue-300×133.png” /></a>
then you need to set the ‘Trigger Type’ to ‘Click All Elements’:


In GTM, if you want to track any HTML element other than a link, then you set the ‘Trigger Type’ to
‘Click All Elements’.

Step-5: Create a new tag with following similar configuration which can send clicks on the tracked
image link to Google Analytics as an event:
Tag Name: Send click on the image download link to GA as event
Tag Type: Universal Analytics
Track Type: Event
Category: Downloads via image link
Action: <<enter the name of your event action>>
Label: {{Page Path}}
Non-Interaction Hit: True
Firing Triggers: Check for click on the image download link 
Step-6: Preview and publish your container.

Step-7: Click on the button and test whether the event data is being sent to Google Analytics, via real
time reports: