Custom Events in Google Tag  Manager

How to define custom conversion events in Google Tag Manager, and why it's a good approach to follow.

Tracking custom analytics events provide a business with the ability to track specific customer actions online that are most valuable, rather than what an analytics platform prescribes as the most valuable. Implementing custom events in various systems can quickly become complex, so it’s a good idea to use a system like Google Tag Manager to distribute what you track to numerous systems at once.

Benefits of Custom Events

This allows your developers to set up event tracking for a single system, resulting in less time spent and minimal maintenance overhead. It also avoids bottlenecks in the future when you need to integrate with new analytics and advertising platforms.

You won’t need to dedicate any engineering resources to support these new systems, you can connect to them within Google Tag Manager directly. It’s an all around recipe for success online, but the key lies in your ability to define and implement custom events that provide the flexibility you need within tag manager to handle any future tracking and advertising tech requests.

To track custom events in Google Tag Manager you’ll need to first set up and install a container for your website or mobile app. Once you have tag manager installed and loading properly you’ll need to work through the following steps.

Sending Events from a Website or App

To send custom events to tag manager you’ll need to push an object into the dataLayer array provided by tag manager. The object can contain any number of arbitrary properties that you can set to whatever you like, but to be seen as a Custom Event in GTM it must include an event property. The value of event property will become the name of your custom analytics event when it arrives in Google Tag Manager.

Here’s an example definition for a “Lead Submitted” event:

dataLayer.push({
'event': 'Lead Submitted',
'form': 'get-started',
'email': '[email protected]',
'url': 'https://www.company.com',
'interest': 'some-product-feature',
});

When this code fires the event will be sent to Google Tag Manager, where you can set up a Custom Event trigger to receive it.

Receiving Events in GTM

Each custom event that is sent to GTM will need to have a Custom Event trigger setup to be received. Custom Event Triggers allow you to fire tags when the event occurs.

Here’s how to set up a custom event trigger:

  1. Open Google Tag Manager
  2. Go to the Triggers menu and click the New button
  3. In the Event name input enter the value you’re sending in as the event property (e.g. Lead Submitted)
  4. Set the This trigger fires on option to All Custom Events
  5. Save the trigger

Sending Events to Analytics & Advertising Tags

At this point you should have sent in information to GTM to track the event, and set up GTM to receive the event with a trigger. The final step to make this work involves firing tags when the event occurs. This can be done under the Tags menu.

Let’s say we want to track this custom event in Google Analytics 4 and Facebook, we can do this using two separate tags, one for Facebook and another for GA. When you create each tag you’ll need to select the custom event trigger under the Triggering section. Each of these tools provides their own definition of similar “lead” events. Using the custom event approach, we can send the naming conventions that both systems expect.

GA4 Event

Google Analytics 4 recommends tracking leads with a sign_up event using this tracking code: gtag("event", "sign_up");.

Facebook Pixel Event

Facebook pixel tracking expects a lead to be tracked using a Lead event using the pixel tracking code: fbq('track', 'Lead');.

Why is it a good approach?

Using our trigger, we can handle both of these in a way that’s clear and easy to understand for anyone else working in our tag manager container. If in the future we implement any additional advertising systems, we’ll be able to quickly track conversions using the same unified trigger with this approach. The naming conventions required won’t matter, we’ll be able to send in whatever each system requires within Google Tag Manager. Overall, it’s a very smart approach for handling analytics and advertising conversion events on the web or in an app.

Meet the Author

Kevin Leary, WordPress Consultant

I'm a freelance web developer and WordPress consultant in Boston, MA with 17 years of experience building websites and applications. View a portfolio of my work or request an estimate for your next project.