Sunday, 24 May 2020

Tracking clicks on a link via Google Tag Manager

Consider the following link on a web page:

<a id=”checklist” href=”http://www.weplan.com/Worksheets/worksheets.pdf”>Download Wedding Planning Checklist</a>

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

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

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

Step-3: Right-click on the link and select ‘Inspect‘ from the drop-down menu:
You will now see the Google developer console window at the bottom of the page:
Step-4: Note down the value of the ‘id’ attribute of the anchor tag (<a>). In our case, it is ‘checklist’. You will need this ‘id’ later on while setting up triggers in GTM.

Note: If you do not find any ‘id’ attribute for the link, you want to track, then look for the unique class name. If you can’t find a unique class name then ask your developer to add the ‘ID’ attribute with a unique value. Without the ID attribute, you can’t easily track clicks on a link via GTM.

Step-5: Navigate to Google Tag Manager and create a new trigger with following similar configurations:
Trigger Name: Check for click on the download link
Trigger Type: Click – Just links 
Check Validation1. Enable this trigger when: Page URL equals <<enter the URL of the page where the link you want to track is embedded>>
2. This trigger fires on: Click ID equals <<enter the ID of your <a> element>>

Note(1):Check Validation‘ ensures that the trigger fires on a successful link click and not just when a user tries to click the link.
Note(2): ‘Page URL’ is a built-in variable of GTM which returns the URL of a web page.
Note(3): ‘Click ID’ is a built-in variable in GTM which returns the ‘id’ attribute of the link clicked.

Step-6: Create a new tag with following similar configuration which can send clicks on the tracked link to Google Analytics as an event:


Tag Name: Send click on the download link to GA as event
Tag Type: Universal Analytics
Track Type: Event
Category: Downloads via link
Action: <<enter the name of your event action>>
Label: {{Page Path}}
Non-Interaction Hit: True
Firing Triggers: Check for click on the download link
Non-Interaction Hit – Set non-interaction Hit to ‘True’, so that event tracking does not affect the bounce rate of your website.

Step-7: Preview your container to make sure that the new tag fires and it fires only when you click on the targeted link.

Step-8: If everything is working as intended then publish the new version of your container.

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

Saturday, 23 May 2020

Components of Google Tag Manager

Google Tag Manager is a free tool that allows you manage and deploy marketing tags (snippets of code or tracking pixels) on your website (or mobile app) without having to modify the code.

“Google Tag Manager helps make tag management simple, easy and reliable by allowing marketers and webmasters to deploy website tags all in one place."

There are three main parts to Google Tag Manager:

1. Tags: Snippets of Javascript or tracking pixels
2. Triggers: This tells GTM when or how to fire a tag
3. Variables: Additional information GTM may need for the tag and trigger to work

What are tags?

Tags are snippets of code or tracking pixels from third-party tools. These tags tell Google Tag Manager what to do.

Examples of common tags within Google Tag Manager are:

  • Google Analytics Universal tracking code
  • Adwords Remarketing code
  • Adwords Conversion Tracking code
  • Heatmap tracking code (Hotjar, CrazyEgg, etc…)
  • Facebook pixels

What are triggers?

Triggers are a way to fire the tag that you set up. They tell Tag Manager when to do what you want it to do. Want to fire tags on a page view, link click or is it custom?

What are variables?

Variables are additional information that GTM may need for your tag and trigger to work. Here are some examples of different variables.


The most basic type of constant variable that you can create in GTM is the Google Analytics UA number (the tracking ID number).


Those are the very basic elements of GTM that you will need to know to start managing tags on your own.