Server-Side GTM Container Recipe Pack (Meta CAPI & GA4 Dual Pipeline)
Production-ready web and server GTM container exports with deduplicated Meta CAPI, Google Enhanced Conversions, and Consent Mode v2 pre-configured.
Architecture Overview & Deduplication Pipeline
This package provides importable web and server GTM container exports to prevent browser signal loss and match browser pixels with Meta Conversions API (CAPI) events.
Key Technical Inclusions
1. Dual-pipeline event routing with deterministic event_id generation. 2. First-party user_data SHA-256 normalisation (E.164 phone and lowercased email). 3. Consent Mode v2 monitoring reading the gcd and gcs parameters. 4. Pre-built CMP bridges for OneTrust, Cookiebot and Termly.
Implementation Code & Script
Client-side dataLayer push format supporting event_id deduplication and SHA-256 Enhanced Conversions user_data.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
event_id: 'order_' + orderId + '_' + Date.now(), // Shared event_id for browser and CAPI dedup
ecommerce: {
transaction_id: orderId,
value: 120.00,
currency: 'AUD',
tax: 10.91,
shipping: 10.00,
items: [
{
item_id: 'SKU_12345',
item_name: 'Performance Running Shoe',
item_category: 'Footwear',
price: 120.00,
quantity: 1
}
]
},
user_data: {
email: 'customer@example.com.au', // Automatically lowercased and trimmed by sGTM variable
phone: '+61412345678', // Formatted in international E.164 standard
address: {
first_name: 'Alex',
last_name: 'Smith',
postal_code: '3121',
country: 'AU'
}
}
});How to cite and attribute this tool
MIT LicenceThis resource is free, open and un-gated under the MIT Open Source Licence. You are encouraged to use, integrate and cite it with attribution:
@misc{geraghty_sgtm_container_recipe_pack,
author = {Geraghty, Gordon},
title = {Server-Side GTM Container Recipe Pack (Meta CAPI & GA4 Dual Pipeline)},
year = {2026},
url = {https://gordongeraghty.com/resources/gtm-analytics/sgtm-container-recipe-pack},
note = {Head of Performance, Empire Amplify}
}Changelog & Version History
v1.0.0Initial production release with Meta CAPI deduplication, E.164 phone normalisation and Consent Mode v2 CMP bridges.