Getting the Most out of Segment/Google Tag Manager Setup

Adam King
4 min readOct 25, 2022
Photo by Firmbee.com on Unsplash

Tips for ensuring you have proper tracking when using Segment and Google Tag Manager.

What is Segment?

Segment is a customer data platform (CDP) made by Twilio that offers users a data hub for their marketing needs. The main products of Segment are Sources & Destinations, Tracking Plans, and User Traits. There is a ton of topics to do a deep dive on when it comes to the platform, but for today I will be focusing on the Sources and Destinations part.

Segment allows you to populate your site with various tracking codes. However, instead of putting a million different pixel codes on your site, Segment allows you to use their tracking codes to send all the information you need into the Segment platform. Anything that sends info into Segment is known as a Source.

Where the real power of Segment comes from, is after the initial digestion of data. Once the information you set up with the previously mentioned tracking codes is in place, you can then map all of that information to various platforms or Destinations.

That means if you want to get Facebook tracking onto your website, you can just set up the Facebook destination, and map the events you already have in Segment, to the standard events Facebook likes.

What is Google Tag Manager?

Google Tag Manager (GTM) is a Tag Management System (TMS) that is used to house and control any media pixels you would like on your site. GTM gives you a nice easy hub to store all of your tags, but that’s not where its power comes from.

The power I am referencing, comes from the ability to customize when and where your tag fires, along with the ability to easily interact with the Document Object Model, and add information to those tags.

Once again, there are many rabbit holes you can go down when discussing GTM, but in the interest of staying on track, I am going to focus on the foundation of GTM, known as the Datalayer.

The Datalayer is just a universal object that is placed on your site when your GTM container loads. GTM was built to seamlessly interact with the Datalayer, and the idea is that any info you want to send to a marketing platform should be included in the Datalayer. Once it is in there, you can easily trigger tags and make custom variables to shoot off information directly to the Ad platform you need.

The Issues

The reason I talk about the power of both Segment and GTM is that unfortunately, this is where a majority of tracking issues stem from.

For GTM, clients rarely have a well-implemented Datalayer, which usually means information needs to be scraped from web pages. Unfortunately, that is the worst place to get information, as a tiny change to the website can throw your tracking off.

For Segment, the issues lie in the tracking codes that are on the website. Whether it be a lack of variables being sent with events, a lack of events being sent in general, or an overflow of events that are no longer needed. The most unfortunate part of tracking code issues is that they are hardcoded on the site, which means you need access to the source code to make changes.

The Solution

Luckily both of these platforms offer a very easy solution for each of the issues highlighted above. The very simple solution is to add a GTM destination to your Segment account.

What this does is create GTM Datalayer pushes for every event that is being tracked in Segment. Obviously the more information you have in your tracking calls the more robust this will make your GTM Datalayer. However this is a very easy way to not only gain some semblance of a Datalayer, but also utilize everything you already have set up in Segment.

The best part of this is that now you have custom events being pushed to GTM that you can use as triggers for tags.

Conclusion

You can use both Segment and GTM for your tracking needs. However, if you end up using both you can get the best of both worlds by utilizing GTM as a destination in Segment.

This not only gives you the option to easily set up pixels for various platforms and let Segment do the heavy lifting for you, but it also provides you the ability to set up tags in GTM, which gives you all of the customization options you want for a tagging setup.

I personally have spent a lot of time in both of these platforms and I continuously see opportunities on how they can be used in unison to provide a healthy and resilient tracking foundation.

As always if you have any questions about what I talked about or disagree with anything I have stated, feel free to reach out to me! You can find me on LinkedIn, and I look forward to hearing any opinions, good or bad.

--

--

Adam King

Software engineer sharing stories of my experiences in a coding bootcamp and beyond.