Description
Prerequisites
- Deploy the SmartTag in Tag Composer with Pages and Clicks plugins and the “ignore empty chapters” box ticked.
- Set up or use a Tag Manager account and add its tracking code to your site.
- Download the master zip in the top description.
Pagetagging.HTML
Tag
Sets a page name based on the URL structure, and a level 2 site based on the domain of the current URL.
Any folder after the third one that isn’t the page, will be added to the third chapter separated by a slash.
Please be sure to edit the following parts :
- Line 1 : the site number (here 123456) so it matches yours
- Line 36 : the URL(s) of your homepage(s) in every format they can be called (with or without the extension file)
- Line 103 to 107 : the hostname defining your level 2 sites
Trigger
Create a trigger to call it on either DOM ready or Page view in GTM.
LinkTagging.HTML
Tag
Sets attributes to each link with the following informations :
- Link type: with the data-click-type attribute based on the href value
- Link position: with the data-click-position attribute based on the iteration of each link in the page
- Link name: with the data-click-name attribute based on the page name previously identified with the page tagging and the inner text of the link
- Link level 2: with the data-click-s2 attribute based on the current page level 2 site id
Please be sure to edit the following parts :
- Line 5 : the domain to define exit clicks
- The other criterias of the link type part, so it matches your urls.
Trigger
The trigger on this tag will be DOM ready or Page view.
It will use a tag sequencing in its advanced parameters to load it after the page tag.
This way variables such as s2 and page name can be used in link tagging.
GTMClickINIT.HTML
Variables
Allows us to stock information in HTML attributes (name, position, type and s2).
These details can be accessed in a Tag with GTM variables, here we will have to declare 4 Data Layer variables:
- Click Name: calling gtm.element.dataset.clickName
- Click Position: calling gtm.element.dataset.clickPosition
- Click S2: calling gtm.element.dataset.clickS2
- Click Type: calling gtm.element.dataset.clickType
Please note the datalayer variables called will match the HTML attributes such as gtm.element.dataset.clickType getting the data-click-type attribute of the targeted element.
Tag
Tag Manager variables must be called in this format ‘{{My variable name}}’.
Based on these variables the GTMClickInit file gets as click label : the current page and the link’s inner text with its position in the page.
Trigger
Google Tag Manager has its own clickListener Trigger, so you can directly set your tag to be fired on any clicked link.
Reviews
There are no reviews yet.