Home Just the Basics Why Google Tag Manager Loves HTML Tags 💘

Why Google Tag Manager Loves HTML Tags 💘

A new acquaintance pointed out that my first blog post doesn’t mention Google Analytics (GA) or Google Tag Manager (GTM) despite every other page on this site saying it’s all about GA and GTM
oops? I’m grateful this caught my attention because I also realized I never gave you any reason to care about HTML tags. Why should you learn it when GTM has so much stuff built in? We’ll get right to it when I return from saying “Google Analytics” to the mirror five times to make better search rankings appear.

Thing 1: Better Context on How Tagging Works

Gaining knowledge is like digging for deeply buried treasure. Sure, you can just muscle straight down. However, you will eventually reach a point you’re too deep to get the loose dirt out of your way. You’ll have no choice but to climb back to the surface and widen the hole a bit to make the bottom more accessible and let you keep searching. Depth of knowledge – while critical – requires at least some breadth. In learning, gaining surrounding context helps us better understand the structures that support our tools and how to leverage them uniquely and powerfully. This is particularly true for web analysts and implementation specialists with at least one of the following aspirations:

You want to do cool stuff in GTM.

There is so much that GTM’s default offerings can’t handle. I can’t blame you; there’s much exciting stuff to explore. If you want your custom build to work, you must know how to communicate instructions to GTM accurately. The first step here is to know how GTM, the client, and the server interact to correctly identify what instructions you need to give GTM. The second step is translating those instructions into a language GTM can understand. GTM doesn’t speak English, but a mix of built-in tags, triggers, and variables; JavaScript; CSS; and HTML (among other languages).

You wanna be the very best


like no one ever was.1 There are plenty of people out there who know all GTM’s tips and tricks. The feats they accomplish with such limited resources are impressive and worth a paycheck. It can’t compare to someone who knows at least a minimal amount of JavaScript, HTML, and how the internet works. Some best practices, such as utilizing a data layer, actually require it. Additionally, there’s more to analytics implementations than the implementation. Client and stakeholder education is equally important.

Most of the time, clients and stakeholders are GA/GTM laypersons. The web analytics field is niche enough that even technical stakeholders – such as web developers – often do not understand how tag management systems work. People don’t like spending money on services when they don’t understand why they need them or what benefit they’ll gain. Educating others accurately, concisely, and clearly requires a deeper and broader understanding of the subject matter, and GTM is no exception.

Thing 2: Debugging Tagging Implementations

A good analyst designs and implements a tagging system and makes it understandable for stakeholders. A great analyst identifies, troubleshoots, and resolves new errors before they significantly impact the data. Every tagging management system has proprietary debugging tools and access to the browser’s development tools. These tools are required to reveal what happened throughout the client-server-GTM interaction. They can’t tell you what went wrong, however. It’s up to you to find Waldo and spot what and where everything became muddled.

Debugging a GA/GTM issue mirrors searching for your misplaced car keys. You trace every seemingly insignificant step back and do a thorough search. You don’t stop until you either find your keys or can’t remember the prior step. In debugging, we start with performing the event that triggers the bug, evaluate the data layer, follow through the network calls, see what GTM does with the API call, and look at the final data in GA4 Debug Mode. So far, so good; the browser’s development tools and Google’s debugging tools can handle all of this for us.2

They can’t compare what we see in each step to what we expect to see and figure out what caused the change. While not technically necessary in every situation, a basic understanding of HTML and how the internet works makes this substantially easier. Every part of your data’s journey – from the user’s interaction to the metrics in GA4 –involves HTML. The site’s base code is HTML, the GTM and GA installation tags are contained within an HTML wrapper, and HTML requests and responses bring in the data: every part of the process is HTML. The ability to parse the chatter helps to identify problems and brainstorm solutions more precisely.

Thing 3: DOM Scraping and Custom HTML Tags

HTML is also a key component of DOM scraping. Without getting into the technical weeds, DOM scraping is when you rummage around a web page’s HTML attributes so you can copy-paste and report their values. Analysts do this all the time to track the text and colors of clicked buttons, the name of a viewed product, or the date of a blog post via custom JavaScript tags within their tag management system.3

If you can help it, you shouldn’t DOM scrape. Just don’t. DOM scraping is like baking. Salt and sugar look very similar, but your bakes will turn out fine if everyone in the kitchen agrees on which is which.  If someone decides salt is sugar, doesn’t tell you, and then you ask them to pass the sugar, you will have some salty cake. Similarly, the tracking implementation will break if nobody enforces naming conventions within a site’s HTML tags and attributes or if the conventions are changed without informing analysts.4

Data layers are the alternative to DOM scraping.5 Chances are, though, that you’ll regularly have to DOM scrape. Implementing data layers front-loads a lot of the work, and clients will often choose the smaller immediate price tag with higher technical debt over a hefty price tag and little technical debt. When you DOM scrape, you will need a good enough understanding of HTML to parse a web document for key attributes and tags.

There’s also a possibility that, since DOM scraping requires a custom setup for each GTM container, you will have to write custom HTML tags to manipulate the data into your preferred format. Tag management systems only help place custom code on a site; they offer no assistance in creating said code.

Where to Go Next

If you’re newer to analytics and/or web development, pause for a deep breath. This probably seems like a lot, and maybe it doesn’t quite make sense yet. And you know what? That’s okay. Learning these things is the first step to moving past being a novice web analyst. It’s a process that won’t happen overnight. The point of this post isn’t to scare you away from more advanced techniques; it’s to excite you by showing the end goal and providing more context as to why this work is an integral part of your journey.

Take a break to grab some water and clear your head. Now that you know why you should know HTML, look at my intro to HTML for web analysts. It introduces the structure of HTML documents, and I will later expand upon it with more technical posts about how tag management systems and analysts utilize HTML. I’m rooting for you, and I’m in your corner. If you have questions, please don’t hesitate to contact me. If you want to learn more about a particular subject, please tell me so I can include it in future content. Thanks for taking the time to read all this, and – as always – stay awesome!


[1] I am not sorry. I will never be sorry.

[2] If you want to learn more about debugging while waiting for me to write about it, go here.

[3] Here’s a helpful article that gets into more detail about DOM scraping.

[4] Blast X wrote an excellent blog post about the pros and cons of data layers and DOM scraping.

[5] Jim is recognized as an industry expert in data layers.

3 Responses

  1. What’s up to all, because I am in fact eager of
    reading this weblog’s post to be updated
    on a regular basis. It carries good information.

Leave a Reply

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

Have a GA/GTM project? I’ll help!

Recent Ramblings