If you try to detect whether a site runs Meta, Google Ads, TikTok, or LinkedIn conversion pixels by scanning its homepage HTML, you will miss a huge chunk of them. On modern ecommerce and SaaS sites, the HTML only has one line:
<script async src="https://www.googletagmanager.com/gtm.js?id=GTM-M28G2G"></script> Everything else lives inside that container. And if you spin up headless Chrome to wait for network beacons, you run into two problems fast: Chrome eats ~300-500MB per instance, and any EU-compliant consent banner blocks the marketing tags from firing anyway.
It turns out gtm.js is not opaque compiled bytecode. Inside the minified JS bundle sits a plain JSON structure containing "macros":[...] and "tags":[...]. You can download the container with a normal HTTP GET and inspect the configured pixels statically in a couple of milliseconds.
What is actually inside gtm.js
If you fetch https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX and search for "tags":[, you will see entries that look roughly like this:
{ "function": "__baut", "vtp_tagId": ["macro", 14] } And nearby in "macros":[, index 14 is often a constant variable ("function": "__c"):
{ "function": "__c", "vtp_value": "187012345" } That ["macro", 14] indirection is why naive regexes over gtm.js miss half the IDs. The tag does not contain "187012345" inline; it points to macro slot 14.
Parsing just the two JSON arrays without a JS parser
You do not need V8, Goja, or a full JavaScript AST parser to read those two arrays. Because encoding/json's json.NewDecoder stops cleanly right after closing the top-level JSON array, you can find the byte offset of "macros":[ and "tags":[ and decode only those slices:
func decodeGTMJSONArray(gtmBody, key string) []any { idx := strings.Index(gtmBody, key) if idx < 0 { return nil } dec := json.NewDecoder(strings.NewReader(gtmBody[idx+len(key)-1:])) var arr []any if err := dec.Decode(&arr); err != nil { return nil } return arr } From there, the resolver is about 120 lines of plain Go:
- Walk
macrosonce and buildconstMacros[i] = vtp_valuefor every entry wherefunction == "__c". - Walk
tagsand skip"function": "__paused"immediately. This alone fixed a pile of false positives for us. Marketers pause old ad pixels in GTM all the time instead of deleting them, and raw regex scanning reports paused tags as active spend. - Resolve each tag's ID property (either a literal string/number or
["macro", N]) against strict format validators:-
__baut-> Bing UET (vtp_tagId/vtp_uetqId) -
__pntr-> Pinterest (vtp_tagId) -
__googtag,__awct,__sp-> Google Ads (AW-...,GT-...) and GA4 (G-...) -
vtp_pixelId-> Meta (14-17 digits) vs Reddit (a2_...ort2_...) -
vtp_bizoId/vtp_partnerId-> LinkedIn Insight Tag
-
- Expand custom
__htmltags. Custom HTML tags in GTM are stored as nested arrays like["template", "<script>fbq('init','", ["macro", 7], "');</script>"]. A tiny recursive walker collapses"template","escape", and"macro"nodes back into plain HTML strings, which we then pass through the same pixel scanner as the homepage.
Two bugs that bit us in production
Criteo vs LinkedIn vtp_partnerId collision. Both LinkedIn community templates and Criteo tags store numeric IDs in a field named vtp_partnerId. Checking that the tag does not carry vtp_partnerType (Criteo) and does carry vtp_conversionId or vtp_eventId stopped us from mislabeling Criteo tags as LinkedIn Insight Tags.
Regex CPU blowups on 400KB+ gtm.js files. Running 15 regexes across a huge minified JS bundle burns CPU fast. Instead, we run a single-pass Aho-Corasick scan for fixed literal anchors (fbq, vtp_pixelId, ttq.load, bat.bing.com/bat.js, etc.), slice a 512-byte boundary-safe window around each hit (extending past trailing word bytes so we never cut an ID in half), and run the platform regex only on that tiny slice.
What this found across 100 real DTC and SaaS sites
When we ran this across 100 Shopify DTC and B2B SaaS domains (with zero browser instances, capped at 256MB RAM):
- 48 out of 100 loaded at least one GTM container.
- Sites like
quince.com(GTM-K2ZKHX64,GTM-5HQ9TQBV) andklaviyo.com(GTM-M28G2G) unpacked 9 distinct paid ad platforms each (Google Ads, Meta, LinkedIn, TikTok, Reddit, Pinterest, Microsoft Advertising, X Ads, plus Criteo/Amazon Ads) purely from static HTML +gtm.js. - 39 out of 100 returned no detectable ad pixels from HTML (many behind strict Cloudflare/Akamai WAF 403 blocks like
whoop.com,bombas.com, andouraring.com). Falling back to public DNS (MX/TXT/SPF/_dmarc) still recovered 7 to 18 verified SaaS tools per blocked domain (Stripe,OpenAI,Anthropic,Slack,Cursor,Google Workspace), and we explicitly emithtmlInspected: false+scanConfidence: "medium"so downstream CRM code does not confuse a WAF block with "this company runs no pixels."
Where static GTM unpacking stops working
To be upfront about the limits:
- Server-side GTM (sGTM): If a company proxies GA4/Meta through
metrics.example.comand fires Meta Conversions API purely server-side, the Meta pixel ID will not sit in the clientgtm.js. - Dynamic JS variables: If a pixel ID is computed inside a custom JavaScript macro (
function == "__jsm") based onwindow.location.hostname, a constant-only macro table will not evaluate it.
For the other ~85% of sites, downloading gtm.js and decoding two JSON arrays beats running Chromium by two orders of magnitude in RAM and latency.
Note: The 100-brand dataset (MIT CSV/JSON) is browsable here: Top 100 Shopify & SaaS Ad-Pixel Index. If you want a hosted runner instead of wiring up the parser, the Go engine is packaged as GTM Ad Pixel Detector and tech-stack-ad-pixel-mcp.