January 22, 2018
More than a year ago, when this blog saw the daylight, my vision was (and still is) to make Analytics Mania No.1 place to find Google Tag Manager resources. Yes, I know it’s next to impossible to surpass Simo’s blog, but hey, let me dream big 🙂
As a result, the library of 30+ GTM recipes was born and its popularity exceeded my biggest expectations. Also, let’s not forget The Ultimate list of 120+ GTM Resources, GTM Checklist (60+ items), huge Google Tag Manager Glossary, etc.
Turns out such thing still does not exist! Or at least I couldn’t find one online. Hmmm.. Time to shine?
Each link will redirect you to a GTM recipe or a blog post (written by me or other authors) which provide detailed installation instructions. For your convenience, I’ve split all codes into categories.
Obviously, this list is not in its final form and will grow in the future so if you haven’t yet, subscribe to Analytics Mania’s updates in the form below.
Do you notice something missing? Do you have an awesome script hiding in your pocket? Let me know in the comments and I’ll include it on the list.
Regular readers of Analytics Mania will (probably) already know a lot of these scrips but I promise that everyone will find something new. Ready? Let’s go!
The appearance of particular elements
#1. Hover Listener pushes events to the data layer about hover interactions that occur over the given CSS selectors in the page.
#2. Custom Element Visibility Listener which tracks when certain elements appear and disappear from the screen (after scrolling up or down).
#3. Soundcloud player listener tracks interactions with embedded Soundcloud player on your site (Play, Pause, and view 25, 50, 75 and 100% of the audio track).
#4. Mixcloud player listener tracks interactions with embedded Mixcloud player on your site (when visitor listens to 25%, 50%, 75% of the audio track. Other possible events are: ‘buffering’, ‘play’, ‘pause’, ‘ended’, ‘error’).
#6. Tab visibility tracking enables you to track when the browser tab with your website in it is hidden or visible.
#9. Exit-intent listener fires data layer event when visitor tends to leave your website.
#10. Print listener tracks when someone prints a page of your website.
#11. Copy text listener tracks when someone copies a text on your website.
#12. Track Facebook comments (embedded on your site).
#14. Track Zendesk (formerly Zopim) chat widget interactions.
#16. Implement Cookie consent when a new visitor lands on your page.
#17. Set cookies in visitor’s browser (then read it via 1st Party Cookie Variable).
#18. Set cookie with page view count. With every page view the counter in the cookie increases by 1. Useful for those who want to fire a particular tag after, say, 3rd page view.
#22. Track form abandonment.
#23. Track form field timing.
#24. Gravity forms listener. In one of my blog posts, how to track form submissions, I’ve explained how to write a custom auto-event listener without coding skills. Gravity forms were chosen as an example.
#25. Contact Form 7 form submission listener.
#26. AJAX form tracking by taking advantage of Lunametrics’ AJAX listener. In fact, you can track any web interaction which is based on this technology.
#27. Pre-fill form fields. This technique is useful when you want to see what was the exact traffic source of each submission (without the need of checking Google Analytics).
#28. Track page load time.
Remember, it’s always better to add SEO stuff (like schemas, meta tags, etc.) directly via code. Anyway, here are some codes (for science).
#31. Add schema markup.
Updated: There is a newer guide how to implement SEO changes via GTM.
#33. Track clicks of Twitter buttons (embedded on your site).
#34. Track clicks of Facebook Like, Send buttons (embedded on your site). Update: Facebook has deprecated Send buttons at all and has also deprecated the ability to track Like buttons. So this list item is obsolete.
#36. Fetch the visitor’s local time and split the traffic into content groups.
#37. Catch visitor’s weather data and send it to Google Analytics.
#38. Custom timer trigger which starts when another interaction occurs (e.g. a click).
#39. Transfer UTM parameters from one page to another. This is useful when cross-domain tracking isn’t possible, you have an intermediate landing page, and you want to transfer its UTM parameters to the next page.
#47-50. Konami codes. Simo Ahava published a listener which captures the famous combination used as a cheat code in video games. I added some minor modifications (found online) and as a result you can now use 4 different Konami codes:
#53. Komito Analytics. A quick-to-install library which automatically tracks various interactions and sends that data to Google Analytics.
I am 100% positive that this list is far from complete. There is still a bunch of useful script wandering somewhere out there. Help me make this library/list/collection/whatever even bigger, therefore make it more useful to readers like you.