Guide to dataLayer Event Tracking with Google Analytics

Google Data Layer Event Tracking Example

When including Google Analytics with Tag Manager you need to use the data layer to store important event activity if you want to send custom events. Our example will demonstrate how to create a trigger in Tag Manager that watches for dataLayer for your event information. This listener in Tag Manager watches for events named gaEvents that are pushed to the data layer. Google has documented this clearly, but we find this is a really common reason that events aren’t getting tracked when we audit website conversion data.

Google Analytics deployed via Tag Manager will not pick up any GA send events like this:


You have the simple option to use auto-tagging, using the GTM interface to track events or use data layer event tracking. For simple sites, you probably don’t need to use this method for event tracking but if a site used ga(‘send’,’event’) previously this is how you can update it using the dataLayer.

Track Conversions with dataLayer Event Tracking

Add the new js to your event tracking wherever the old ga(‘send’,’XXXX’,’XXXX’) was used or where you want to trigger an event from in a new project. We’ll create the events using the dataLayer push code.

Use this code to push event data to the data layer, to be picked up by Tag Manager to create events in GA:

‘event’: ‘gaEvent’,
‘eventCategory’: ‘somecategory’,
‘eventAction’: ‘someaction’,
‘eventLabel’: ‘somelabel’

Add the above code, to push events to the Data Layer wherever needed, and remove the old ga(‘send’,’XXX’,’XXXX’) code.

Adding the Analytics Event Tracking

In Tag Manager, configure a new tag for Univeral Analytics to track an event.

Our example has three event parameters which will use variables: eventCategory, eventAction and eventLabel.

For the category, action, label, and value (if set) you will need to create a variable in Tag Manager and the variable type should be ‘Data Layer Variable’ for each event tracking parameter.

Assign those variables to the appropriate fields in the event tag.

Setup a trigger based on a custom event. The event will be the gaEvent based on my example above.

You can easily test your event by using the console in Chrome’s inspector window and watch real-time events reporting in GA. If it works you should see your event in there after running the console test.

To verify, check the event in real time reporting on Google Analytics. You’ll now be able to track all of your events sent to the data layer with that single event trigger setup in Tag Manager.