Using GTMSpy to spy on GA4

PUBLISHED 4 Jun 2023 - UPDATED 15 Aug 2023

GTMSpy doesn't support GA4 (Google Analytics 4) tags, but in some cases it can still be used to get insights on whether a site uses GA4. Here's how.

GTMSpy and GA4

GTMSpy (https://gtmspy.com) is a great free tool for 'spying' on any Google Tag Manager container. It lets you see the contents of, and export, the container even if you haven't been granted access to the container or GTM account.

But it has one big limitation - it doesn't support Google Analytics 4 tags. GA4 Event tags and Configuration tags just don't show up at all when you spy on a container that contains them. And it looks like its creator, Dustin Recko, has no immediate plans to fix this.

Does that mean GTMSpy is useless for getting intel on whether a site uses GA4? Not necessarily, but it depends on how GA4 has been implemented within GTM for that site.

Every site using GA4 has a so-called Measurement ID, with the format G-XXXXXXXXXX. This Measurement ID is added to the GA4 Configuration tag - but there are at least three ways to do that. And two of them do leave evidence in GTMSpy.

Measurement ID as a Constant

The first way to implement GA4 in GTM is by creating a 'Constant' variable with the Measurement ID as its Value, then using this variable in the GA4 Configuration tag. This is actually the approach I take on this site. So here is my Constant variable:

GA4 Measurement ID as Constant variable in Google Tag Manager

And here is my GA4 Configuration tag making use of that variable:

GA4 Configuration tag using Constant variable in GRM

The benefit of this approach is that if I reference the Measurement ID in more than one place, I can update all those references at once just by updating the variable.

And variables (unlike GA4 tags) do show up in GTMSpy, so if you 'spy' on my site you would be able to see my Constant variable like so:

Constant variable with GA4 Measurement ID in GTMSpy

This tells you:

  • That GA4 is in use on this site
  • What the Measurement ID is
  • A little bit about how it has been implemented

Better than nothing, right?

Measurement ID in Lookup Table

The second way to implement GA4 in GTM is by using a Lookup Table variable to specify the Measurement ID. This is often the case when a single GTM container is used on multiple websites. Of course, it only makes sense to do that if all the sites have very similar tracking requirements.

With this approach, the lookup table has each site's page hostname as the input, and the Measurement ID as the output. The table also has an optional default value, also likely to be a Measurement ID.

I've taken this approach myself with a client but I can't share that as an example, so here's a quick mockup for you instead:

Lookup Table variable in GTM with Page Hostname as input and GA4 Measurement ID as output

Then this Lookup Table variable is used in the GA4 Configuration tag:

GA4 Configuration tag in GTM using Lookup Table as Measurement ID

Again, the GA4 Configuration tag won't show up in GTMSpy but the Lookup Table variable will. The tool shows you the default value for the variable:

GTM Lookup Table variable in GTMSpy

And click on [LIST] to see the entire table (hostnames and corresponding Measurement IDs) in an overlay:

Lookup Table List in GTMSpy

This tells you:

  • That GA4 is in use on this site
  • That this container is also used on other sites (which presumably have very similar tracking requirements)
  • Which other sites it is used on

Measurement ID directly in Configuration tag

The third way to implement GA4 in GTM, and sadly I suspect the most common, is by adding the Measurement ID directly into the GA4 Configuration tag like this:

GA4 Measurement ID in GA Configuration tag in Google Tag Manager

I say 'most common' because it's the approach that GTM advises you to take in the little tooltip next to 'Measurement ID'. This says: "Enter the Measurement ID (e.g, G-A2ABC2ABCD) for your GA4 property."

And I say 'sadly' because it means there's nothing for GTMSpy to spy. It won't see the Configuration tag, and with this approach there are no GA4-related variables for it to report on instead.

This means that if GTMSpy draws a blank, a site may or may not be using GA4. Remember that absence of proof is not proof of absence! You will just have to continue your investigation some another way.

Subscribe
Notify of
guest
2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Brett L
Brett L
8 months ago

If you go to the console in your browser and enter

it will give you the site's GA4 Measurement ID, GTM Container ID, and Google Optimize ID even if the Measurement ID was directly added in the Configuration tag.

James Clark
Hi! I'm James Clark and I'm a freelance web analyst from the UK. I'm here to help with your analytics, ad operations, and SEO issues.
2
0
What do you think? Leave a commentx
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram