Guide to dataLater Event Tracking with Google Analytics

When Google Analytics is setup via Tag Manager it will not pick up an event like this: ga(‘send’,’event’,’somecategory‘,’someaction‘)

When including analytics with tag manager use the data layer to store the event activity and create a trigger in tag manager to watch for the event. We’re creating a listener for tag manager on the dataLayer to pick up the data stored with any events named gaEvents that are sent. Google has documented this clearly, but we find this is a really common reason that events aren’t getting track when we audit websites.

You have the 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 the data layer event tracking. But if a site used ga(‘send’,’event’) previously their might still be a need.

Example dataLayer Event Tracking Setup

First add the new js to your event tracking wherever the old ga(‘send’,’event’)  were used.

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, using {{varibale}} wherever needed, and remove the old syntax.

In Tag Manger, setup a new tag for Univeral Analytics, tracking an event. For the category, action, label and value if set you will need to create a variable (type will dataLayer variable for each data point. In my example above there are 3- eventCategory, eventAction and eventLabel.

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

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

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

If you aren’t seeing the event in real time reporting on Google Analytics something is likely missing and the configuration needs to be checked. If it’s working, you can now track all of your events sent to the dataLayer with that single event trigger setup in tag manager.