Attaches event listeners to the addthis object and pushes them to GTM's dataLayer.
Necessary because AddThis' built-in GA "integration" doesn't work with Universal Analytics, or GTM. 😒
See also:
- AddThis docs
- Simo Ahava's guide to generic Event passthrough.
- Export an example implementation from our Container.
Adapted from @skardhamar's work.
- Create the Generic Event tag, trigger & variables as per Simo's guide.
- Create a Tag of type 'Custom HTML', and copy the contents of
addthis.gtm-tag.html
into it. - Set the Trigger to be 'All Pages', or preferably some Page Load that will only fire on pages where AddThis is used.
- Test with Preview Mode and the Tag Assistant.
From a blog list view, clicking an article's "Share to Twitter" AddThis button:
{
"remoteEvent": {
"data": {
"imp_url": 0,
"url": "https://www.wnswlhd.health.nsw.gov.au/our-health-blog/Lists/Posts/Post.aspx?ID=32",
"title": "Learn And Grow' During Mental Health Month",
"smd": {
"rsi": null,
"gen": 0,
"rsc": "",
"dr": "",
"sta": "AT-ra-56df8902d0735ca1/-/-/58043433d818d092/1"
},
"service": "twitter",
"element": null
},
"type": "addthis.menu.share",
"triggerType": "addthis.menu.share",
"target": {},
"triggerTarget": {}
}
}
- Is there a better way to know when the AddThis object is ready?
- Is there a practical way to know whether AddThis is in use on a page?