Event Tracking with Data Attributes in GTM

This article was written for Universal Analytics, which will stop processing data in July 2023 as Google switches to GA4. While the underlying HTML/JS techniques can be carried over, GA4 requires almost completely new configuration. Check out Google's migration guide here, or, for a complete done-for-you solution, I recommend Mediauthentic. . One common method of ... Read more

Useful Custom JavaScript Variables for Google Tag Manager

This post shows some useful Custom JavaScript Variables for Google Tag Manager. #2 and #3 require modification for your own site, while the others can be plugged in directly. Add Custom JavaScript Variables by navigating to Variables > New > Custom JavaScript. CONTENTS #1 Value of the Closest Parent ID#2 Text of the Closest Specific ... Read more

DOM Scraping Together a Datalayer for Google Analytics Ecommerce Tracking

Google Analytics' e-commerce tracking is generally the most developer-intensive part of a Google Analytics implementation, because it requires a developer-built data layer on the transaction confirmation page. The data layer collects all the relevant data -- the transaction ID, the checkout total, the product names, the prices, and so on -- and lays them out ... Read more

Track Number of Search Results in Google Analytics with GTM

Tracking the number of onsite search results is useful for finding common searches for which few, or zero, results were returned, so that you can address gaps in your product or content offerings. This metric can also be used to analyze the correlation between search result counts and conversion rates. While the built-in onsite search ... Read more

Google Analytics Event Tracking in Google Tag Manager

There are many types of site interactions you may be interested in tracking: scroll distance down a page, clicks on a hero image, email address submissions, and so on. All of these can be tracked using Google Analytics' event tracking tags, which in turn can be set through Google Tag Manager (GTM). GTM is a ... Read more