Save Money And Time With Our #5 Rules For A Clean And Scalable GTM Architecture

Magda Baciu - October 27, 2020


If you have already started using Google Tag Manager you may know that this tool is based on tags, triggers and variables. 

The way you are using these concepts will make the difference between:

  • An easy-to-break tracking implementation and a scalable architecture in Google Tag Manager
  • Creating/updating a data tracking setup in 2-3 hours vs 10-20 minutes

That’s about 19 hours saved every 10 updates you need deploy in GTM

19 hours of your life you could save at a blink of an eye

So we decided to show you how we go about efficiently creating an architecture in GTM here at House of Progress.

Stay with us for more information on how to deal with tags, triggers and variables to optimize your tracking implementation.

Tags. Triggers. Variables. What are these?

Implementing tags, triggers and variables is easy if you know the scope for each element.

Variables – are used to get/collect information.

Triggers – are used to select the moment when you want to send information.

Tags – will structure the information that will be sent.

In other words,

  • you will configure a tag with specific variables that contain the information you need
  • and select a trigger that will send that information when you want.

🧐 Example

Let’s say you want to track a Facebook Share button, to send this data to Google Analytics which is valuable to see what type of content motivates people to share.

So what’s the variable in here if you look at what we have behind the curtains?

It’s the a href one as this is the only aspect that code wise tells apart the Facebook button from all the other social media buttons (because we want to independently track all these website micro behaviours).

The Variable

  • Firstly, we will need a Custom Javascript variable that sends along the type of social media button. This variable should look like you see below.

  • Basically, this variable will check the href attribute for every social button type that was clicked and send the info to Google Analytics

The Trigger

Now let’s focus on the trigger.

Do you want to track these buttons on specific pages? Or across the website?

You can do both.

But don’t forget to add a triggering condition if you want the tracking active on specific pages

Below you can see how the trigger configuration would look like if we want to setup the event site-wide

The Tag

And finally, to put everything together this is how you will structure your tag.

Tadaaa! 🥳

That’s all.

Now that you understand what Tags, Triggers & Variables are, let’s see how you can build a scalable GTM architecture that saves you that time we were talking about at the beginning.

Rule #1: Build a measurement plan you can share with any data stakeholders

The GTM architecture should mirror the measurement plan.

And the measurement plan structure has two consider 3 types of aspects:

  • business model
  • website/app technical architecture
  • general and custom data accuracy issues we need to solve

There is no one universal or perfect measurement but you can download a template of ours – here.

Note: the {} are used to indicate that we collect dynamic data

We’ll get back with an article where we’ll focus on building a measurement plan from scratch, nonetheless, there is one simple aspect I think it’s useful to mention.

More specifically, structuring Event categories/actions and label

Going back to our specific example above, we’d have the following structure

  • Event Category
  • Event Action
  • Event Label

So many times, we get access to Google Analytics accounts where we see thousands of events chaotically implemented so as a data analyst or marketer you have no clue what to start with and what’s what. Who is going to use that data if as data engineers we don’t provide a good experience for the end-user?

Rule #2: Use a naming convention that’s easy to understand

This goes for each section of the Measurement Plan and GTM architecture alike

Fastly understanding the purpose of each setup is a blessing, if we can say so, for all the people working on data implementation, data analytics and anything that includes leveraging data

Keep things clean, structured, easy to understand

Here at House of Progress, we are a bit crazy about structures and the UX of each output we build.

And that’s obvious as you look below.

We do have naming conventions for each GTM concept

Naming Convention for Tags:

  • [Page or Section] [Number of item in Measurement Plan] [Short description] – [Type of Tag]

🧐 Examples:

  • Homepage 1. Social Share – UA
  • Blog 3. Click on Article – UA
  • Global 1. Scroll Depth – UA

Naming Convention for Triggers:

  • [Page or Section] [Number of item in Measurement Plan] [Short description] – [Type of Trigger]

🧐 Examples:

  • Blog 3. Click on Article – Click
  • Global 1. Scroll Depth – Scroll Depth Event
  • Contact 4. Form Submit – Custom Event

Naming Convention for Variables:

  • [Type of Variable] – [Short Description]

🧐 Examples:

  • JS – Social Media Type
  • DataLayer – Page Name
  • Constant – UA Tracking Account ID

Rule #3: Create a seamless GTM folders structure

By default, GTM creates a general folder named Unfiled Items for every element

And you don’t want that

What you actually want is to have all your tags, triggers and variables in folders by type

Our suggestion is to consider structuring the implementations in the folders you see below

  • Folder for Pageview: Pageviews
  • Folder for Events: Events
  • Folder for Variables Variable – [Type of Variable] (eg: DataLayer, Custom JS, Constant)
  • Folder for Custom HTML  Tags – Custom HTML
  • Folder for 3rd Party Tags – Third Party

Rule #4: Keep the IDs and classes unique

It’s very important to have unique IDs and classes, in order to track data accurately. If you don’t want to have all tracking based on dataLayer custom events, you could rely on your pages’ HTML code for tracking specific element click.

Elements that are going to be tracked must have a unique attribute, otherwise it’s impossible to have accurate data. For example, you could use an element’s ID or a specific class, but the best practice is for the HTML to contain a custom attribute such as “analytics-click-action” that contains meaningful information.

Let’s take the first example in this post, where we tracked the click on the social media button. We could use that class because we knew it was a class specific for social media and there is no risk that another button will have that class. However, if the element would have had a class like “button” or “btn” there would have been a very high probability that other buttons which we didn’t want to track would use this class as well. In this case, the class choice would have been inappropriate.

Rule #5: Leverage dataLayers wherever you can

One of the most important sources of information for GTM is the dataLayer.

What’s its unique power?

It helps you store all the information you need on the page and then use it anytime.

Basically, the dataLayer is only a javascript code, an object that contains information as key and value.

Let’s assume you are in charge of a publishing website similar to Forbes

And you 200 authors publishing content, 3 different business categories: Leadership, Money, Business

Wouldn’t it be cool to go into Google Analytics and measure the content performance by author and/ or category?

Yes, it would be cool and extremely powerful when it comes to improve website revenue

🧐 Example:

Just one example on the data activation side or how you can actually help you business grow by tracking this type of data

  • People read about specific content topics and they might even admire specific authors/writing styles
  • AND we want to know this, isn’t it? Dynamic retargeting ads based on interests and preferences always works wonderful.

But it goes beyond this

You could also identify what’s the type of content you should scale up, what elements to emphasise on your homepage in order to generate the best engagement with that new video, or even what price range works best for selling pijamas to people that are interested in turtles (who isn’t?).

See? When it comes to juggling with the data you have available, the world becomes your oyster.

So the more quality data you can pull from the dataLayer, the better.

Ok, so now let’s go back to the more technical things

We know what we want to track and why

So let’s do it!

Let’s assume that our article is written by ’Michael M’ , and he writes about topics related to Analytics

So we want to store this info a data-layer and send it to Google Analytics

Step 1: Collect Information

As you can see the dataLayer can contain essential information that you need and it is very easy to collect it in GTM.

And you only need to:

  • The only thing you have to do is to create a new Variable and select Data Layer Variable type
  • Then insert the key to the information (author in our case)
  • So you have the variable that collects that information and you can use it in a tag or a trigger as a condition.

Step 2: Add variable to Tag

Adding a dataLayer variable in your implementation can be done in two ways:

  • Data Layer type variable as a custom dimension in Google Analytics Settings Variable (this way you will add that custom dimension for every tag that use that GA Settings variable)
  • Data Layer type variable as a custom dimension in a specific tag, so only that tag will contain the new dataLayer variable based custom dimension

Extra: Triggers based on dataLayer

As we have already mentioned:

  • you can add that Data Layer type variable as a condition to a trigger
  • but you can also create a trigger based on a custom dataLayer event.

The best example here is for a form success, when you have a form and you want to track when the user successfully submitted the form.

You can ask the developers or create your own Custom HTML tag that will return the following code when the form submitted successfully conditions are met: dataLayer.push({event: ‘FormSuccess’});
And this is how your trigger should look like after:


Thanks for staying with me until the end. I know the ride wasn’t easy at all points, but hopefully you got a better understanding upon building a clean and scalable tracking architecture in GTM. This will allow you to scale if needed and make new implementations easier in the long run.

Remember to always keep an eye on your tags, triggers and variables, and organize them in a way that is easy to use bu your team.

Here is another extra tip – Having all the tracking in GTM organized in a logical and easy to understand manner, will allow you to quickly loop in another colleague whenever needed, making it easier for him to understand how things are organized. As an agency, we find this one specifically very important.

Please feel free to reach out if you have any questions, or suggestions of other cool things that improved your GTM tracking architecture, or if you just want to exchange ideas with us.

See you next time!

Leave a Reply

Your email address will not be published. Required fields are marked *



Analytics & Processes You can Apply Straightaway



Templates & Processes in Your Inbox

Send me occasional emails


I agree to the Privacy Policy

Send me occasional emails


I agree to the Privacy Policy