GTM Analyzer
Download
Download GTM Analyzer — zip containing the script and README.
Parses a GTM JSON export and writes structured CSVs + a full JSON dump. Run it any time you need a readable breakdown of a container — tags, triggers, variables, folder structure, consent settings, and paused status in one pass.
Folder structure
scripts/resources/gtm/
├── gtm-analyzer.js — the analyzer script
├── template/
│ ├── current/ — active Pacing base container exports (committed)
│ │ ├── GTM-PGPK24VR_workspaceN.json
│ │ └── GTM-NHVBMP3D_workspaceN.json
│ └── archive/ — previous versions (committed)
│ ├── GTM-PGPK24VR_workspace11.json
│ └── GTM-NHVBMP3D_workspace10.json
└── outputs/ — analyzer runs (gitignored; re-generate from template/ as needed)
└── YYYY-MM-DD_HH-MM_<container-id>/
Client exports go in test/GTM/ (gitignored at repo root). Never commit client container JSONs.
Workflow — updating to a new template version
- Export new workspace JSON from GTM: Admin → Export container → Current workspace.
- Archive the current JSONs: move
template/current/*→template/archive/. - Drop the new JSONs into
template/current/. - Run the analyzer on both containers (see usage below).
- Audit — open the new CSVs and compare against the previous run in
outputs/. Look for:- New or removed tags
- Paused tags that are now active (or vice versa)
- Renamed or added
- Changevariables (per-client config points) - Trigger changes that affect routing or consent
- Update docs based on findings:
- GTM — workspace references and container highlights
- GTM Template Guide — add a row to the version history table
- Web Container — update tags/triggers/variables tables
- Server Container — same for server
- Commit — template JSONs in
template/current/+ archived old ones + doc changes. Outputs stay gitignored.
Usage
node scripts/resources/gtm/gtm-analyzer.js <path-to-export.json> [output-dir]
Examples
# Pacing web container (current template)
node scripts/resources/gtm/gtm-analyzer.js scripts/resources/gtm/template/current/GTM-PGPK24VR_workspaceN.json
# Pacing server container (current template)
node scripts/resources/gtm/gtm-analyzer.js scripts/resources/gtm/template/current/GTM-NHVBMP3D_workspaceN.json
# Client export (drop in test/ which is gitignored)
node scripts/resources/gtm/gtm-analyzer.js test/GTM/GTM-XXXXX_workspaceN.json
Output files
Each run creates a new timestamped subfolder (outputs/<timestamp>_<container-id>/) so previous runs are never overwritten.
| File | Contents |
|---|---|
tags-summary.csv | All tags: type, folder, firing/blocking triggers, consent, paused status, description |
triggers-summary.csv | All triggers: type, folder, human-readable filter conditions |
variables-summary.csv | All variables: type, folder, description |
tags-full.json | Full tag objects (HTML/template values truncated to 300 chars) |
How to export from GTM
- Open tagmanager.google.com
- Select the container and workspace
- Admin → Export container → Current workspace
- Download the JSON file
- Run the analyzer against it
Notes
- The script auto-repairs a known GTM export bug where truncated base64 image thumbnails in custom templates produce invalid JSON (affects server containers with Stape custom tags).
- Variables ending in
- Changein the Pacing template are per-client customisation points. - Client export drops should go in
test/GTM/(gitignored). Never commit client container JSONs to the repo.
See the Pacing GTM Template guide for full documentation on these containers.