Skip to content

GTM Event ID Deduplication Variable (Web & sGTM)

Open-source Apache-2.0 custom variable template for Web and Server-Side GTM. Generates collision-resistant event_id keys to deduplicate browser pixels against Meta CAPI and GA4 Measurement Protocol.

By Gordon Geraghty·Apache-2.0 Licence·Updated: 28 November 2026·INTERMEDIATE
01 Prerequisites & Architecture
Stage 01 Architecture

GTM Event ID Deduplication Variable (Web & sGTM) Architecture

Difficulty:Intermediate Engineering
Time:20–30 mins
Required Access & Permissions:
GTM AdminGCP Editor / IAMAPI Credentials
STEP 01Client-side Web SDK
Client Browser / EventUser interaction & DOM event triggers
STEP 02Edge Gateway / Worker
Ingestion EndpointValidation, schema verification & rate limit
STEP 03Transform Engine
Processing PipelineEnrichment, hashing & parameter mapping
STEP 04Cloud Destination
Destination / WarehouseDownstream analytics, ads API or BigQuery
02 Interactive Configurator

Interactive Configurator

INSTRUMENT BOUNDARIES

GTM Event ID Deduplication Variable (Web & sGTM) — Scope & Limitations

Explicit operational boundaries and constraints defining target use cases and out-of-scope scenarios.

Built For (Target Use Cases)

  • Dual Web + Server-Side GTM setups running Meta Pixel and Meta CAPI in parallel
  • GA4 client-to-server event pipelines requiring consistent transaction or lead deduplication
  • Teams wanting an Apache-2.0 sandboxed .tpl variable without custom HTML script tags

Not Built For (Limitations & Out-of-Scope)

  • Purely server-side implementations with no browser pixel firing
  • Cross-session identity stitching (event_id is scoped to a single event)

Operational Assumptions & Defaults

  • Web GTM forwards the generated event_id into the GA4 or custom event payload consumed by sGTM
  • Meta CAPI and pixel tags both reference the same variable per trigger evaluation
03 Deployment & Production Recipes

Production Implementation

Copy or export the production configuration directly to your codebase, CI/CD pipeline, or infrastructure.

Export & Deployment Actions1-click clipboard transfer, shareable URL hash, and local file downloads.

04 Verification Checklist

Production Verification Checklist

Ensure all functional and architectural requirements are met before promoting to production.

When running browser pixels alongside server-side conversions (Meta CAPI, GA4 Measurement Protocol), both pipelines must emit an identical event_id per user action so ad platforms deduplicate rather than double-count.

This sandboxed GTM custom variable template generates deterministic, collision-resistant event_id keys that persist cleanly between Web GTM tags and Server-Side GTM clients.

How to cite and attribute this tool

Apache-2.0 Licence

This resource is free, open and un-gated under the Creative Commons Attribution 4.0 (CC BY 4.0). You are encouraged to use, integrate and cite it with attribution:

Geraghty, G. (2026). GTM Event ID Deduplication Variable (Web & sGTM). Gordon Geraghty Resources Hub. https://gordongeraghty.com/resources/gtm-event-id-deduplication-variable
BibTeX Format
@misc{geraghty_gtm_event_id_deduplication_variable,
  author = {Geraghty, Gordon},
  title = {GTM Event ID Deduplication Variable (Web & sGTM)},
  year = {2026},
  url = {https://gordongeraghty.com/resources/gtm-event-id-deduplication-variable},
  note = {Head of Performance Media, Empire Amplify}
}