Open your Google Tag Manager container and count the tags. If the number is over 100, we will bet that nobody on your team can say what a third of them do, who asked for them, or whether they still fire. GTM containers grow by accretion: every campaign, agency, and vendor trial leaves a tag behind, and nobody ever deletes anything because nobody knows what will break. Stop auditing containers by clicking through the interface. Export the live version through the Tag Manager API, run deterministic checks in code, and use an LLM for the one job rules cannot do: reading Custom HTML and explaining what it actually does.
Why Manual GTM Audits Never Finish
The GTM interface is built for editing one tag at a time, not for reasoning about 300 of them. A manual audit means opening each tag, checking its triggers, opening each trigger, and cross-referencing variables in your head. It takes days, it is out of date the moment the next version publishes, and it consistently misses the riskiest category: Custom HTML tags.
Custom HTML is where the real problems live. A pasted vendor snippet can load additional scripts from domains you never approved, read form fields, write cookies before consent, or block the main thread on every click. The tag name says "LinkedIn Insight - Q3 Promo." The code says something else entirely. Reading that code is exactly the kind of tedious, pattern-heavy work a language model does well, as long as you give it structure and keep it away from decisions it should not make.
Step 1: Export the Live Container as Data
The Tag Manager API v2 exposes the published container version as a single JSON object. Call the accounts.containers.versions.live endpoint with a read-only scope (tagmanager.readonly) and you get back arrays of every tag, trigger, and variable, including each tag's type, parameters, firing triggers, and paused state.
Audit the live version, not a workspace. Workspaces contain drafts and experiments. The live version is what your visitors actually execute, and it is the only version that matters for risk.
Store the export in a repo with a date in the filename. Two exports a month apart, diffed, will tell you more about how your container drifts than any audit document ever has.
Step 2: Run Deterministic Checks First
Do not hand the whole container to a model and ask "what is wrong with this?" You will get a confident, partly wrong essay. Most container problems are structural, and code finds them with zero ambiguity. A short Node or Python script should flag:
- Paused tags. Anything with
paused: truefor more than one release cycle is dead weight. Delete it or document why it stays. - Orphaned triggers and variables. A trigger that no tag references, or a variable nothing reads, is clutter that makes the next audit harder.
- Tags with no firing trigger. These never run and usually indicate a half-finished migration.
- Duplicate measurement IDs. Two Google tags or two pixels with the same ID double-count conversions. Group tags by type and ID and flag collisions.
- Hardcoded IDs. Measurement IDs typed directly into tags instead of a constant variable break the moment you change properties.
- Consent coverage. Every advertising and analytics tag should declare consent requirements. List the ones that do not.
This pass typically shrinks the problem dramatically. Of 300 tags, maybe 40 are Custom HTML, and those are the only ones that need a model.
Audit Thresholds Worth Enforcing
Maximum time a tag can stay paused before it is deleted
Custom HTML tags allowed to load a domain not on your approved list
Tags with a named owner in the tag notes
Write these thresholds into the script as failing checks, not suggestions. A container audit with no pass or fail condition is just a report nobody reads.
Step 3: Let the LLM Read Custom HTML, With a Schema
For each Custom HTML tag, send the model the tag name, its code, and its firing triggers, and require a structured response. A schema keeps the output machine-checkable and stops the model from rambling. Ask for these fields:
{
"tag_name": "LinkedIn Insight - Q3 Promo",
"purpose": "Loads LinkedIn Insight Tag and fires a conversion on form submit",
"external_domains": ["snap.licdn.com", "px.ads.linkedin.com"],
"reads_user_input": true,
"sets_cookies": true,
"blocking_script": false,
"likely_vendor": "LinkedIn",
"native_template_available": true,
"risk": "medium",
"risk_reason": "Reads form fields before consent check; native template exists"
}
Three rules keep this honest. First, verify what can be verified. The script should extract external domains with a regex and compare them to the model's list. If they disagree, the code wins and the tag gets flagged for a human. Second, the model classifies and explains; it never deletes, pauses, or edits anything. Every change still goes through a person and a GTM version publish. Third, strip anything sensitive before sending. Custom HTML sometimes contains API keys or internal URLs, and those do not belong in a third-party model call. If that worries you, a small local model handles this classification task fine.
The native_template_available field is where the quick wins hide. A large share of Custom HTML tags are vendor snippets that now have an official Community Template Gallery equivalent, which runs in a sandbox with declared permissions. Swapping a raw snippet for a sandboxed template is the single best security upgrade most containers can make.
Step 4: Turn the Output Into an Owned Report
The output of this pipeline is not a slide. It is a table in your repo or warehouse with one row per tag: type, triggers, status, risk, plain-language purpose, and an owner column you fill in. Sort by risk. Send each owner the tags they are responsible for and give them two weeks to confirm, fix, or approve deletion. Anything unclaimed after two weeks gets paused, and anything paused for a full cycle gets deleted.
Then schedule it. Run the export and checks weekly in CI, diff against last week, and post new Custom HTML tags or new external domains to Slack. The audit stops being a project and becomes a monitor.
GTM Container Audit Pipeline Checklist
- Service account with tagmanager.readonly scope exports the live version
- Exports stored in a repo with dated filenames for diffing
- Script flags paused tags, orphans, duplicate IDs, and missing consent settings
- Custom HTML tags sent to an LLM with a strict JSON schema
- External domains verified by regex, with mismatches flagged for review
- Every tag assigned an owner, with unclaimed tags paused after two weeks
- Weekly CI run posts new tags and new domains to Slack
Start With One Export This Week
You do not need the full pipeline to get value. Pull the live version JSON once, count your Custom HTML tags, and run them through a model with the schema above. You will almost certainly find a vendor you stopped paying, a script loading from a domain nobody recognizes, and a pixel firing twice. Fix those three, and you have already justified building the rest.
Tags
LETSGROW Dev Team
Marketing Technology Experts
Ready to Apply This Insight?
Schedule a strategy call to map these ideas to your architecture, data, and operating model.
Schedule Strategy Call