Skip to main content

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

  1. Export new workspace JSON from GTM: Admin → Export container → Current workspace.
  2. Archive the current JSONs: move template/current/*template/archive/.
  3. Drop the new JSONs into template/current/.
  4. Run the analyzer on both containers (see usage below).
  5. 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 - Change variables (per-client config points)
    • Trigger changes that affect routing or consent
  6. Update docs based on findings:
  7. 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.

FileContents
tags-summary.csvAll tags: type, folder, firing/blocking triggers, consent, paused status, description
triggers-summary.csvAll triggers: type, folder, human-readable filter conditions
variables-summary.csvAll variables: type, folder, description
tags-full.jsonFull tag objects (HTML/template values truncated to 300 chars)

How to export from GTM

  1. Open tagmanager.google.com
  2. Select the container and workspace
  3. Admin → Export container → Current workspace
  4. Download the JSON file
  5. 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 - Change in 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.