DEV Community

loading...

make your dev mgr AND your mktg mgr happy by migrating to google tag manager based analytics today

osde8info profile image Clive Da ・1 min read

google are moving users away from the old google analytics javascript and analytics ids to new google tag manager javascript and google tag manager ids

https://www.bounteous.com/insights/2017/03/23/10-reasons-start-using-google-tag-manager-right-now/?ns=l

https://www.crazyegg.com/blog/easy-google-tag-manager/

https://developers.google.com/tag-manager/devguide#migration

https://developers.google.com/tag-manager/quickstart

NOTE when choosing to use a single container across multiple domains, it's important to carefully configure your tags and triggers within Google Tag Manager. Using the default “All Pages” trigger in Google Tag Manager (i.e. $url matches RegEx) will fire tags on all pages of all domains on which your container snippet is deployed.

here is an example of how to use node, node-fs, express and pug to dynamically generate HTML and JS that includes your NEW google tag manager id from your ENV so that if someone clones your @glitch or @zeit node project they DONT get a copy of your GTM ID :)

the top of your rendered html should end up like this note the code between the "Google Tag Manager" comments

server.js

index.pug

gtm.js

the entire project on glitch

the entire project on github

GitHub logo osde8info / glitch-mapsaw

glitch mapsaw node express pug




see also

https://dev.to/dennisview/cookie-free-google-analytics-23gj

https://dev.to/yashints/setting-google-analytics-for-angular-applications-45k6

Discussion (0)

pic
Editor guide