Gateway browser bridge (GTM Custom HTML tag)
The client had three competing GTM scripts firing on the same form_submission conversion, each with a different payload shape. Consolidating on one risked silently dropping identifiers already being sent. The work started by establishing ground truth: rather than picking the most complete-looking script, each candidate was diffed against the canonical the Gateway Internal Event schema in the internal client-integration-guide Skill's generate_guide.py. That comparison settled which payload shape the Gateway accepts (client slug in the URL path, properties not custom_data, event_id and consent required) and exposed that an earlier merge had been built on an invalid base. The final tag performs a strictly additive merge: the base script's click id sweep across gclid, gbraid, wbraid, fbclid, fbc, fbp, msclkid, ttclid, ttp, rdt_cid and li_fat_id (URL first, first-party cookie fallback) is preserved byte-for-byte, with event_id, external_id, properties, consent, metadata and the Gravity pixel CAPI context grafted in. Two conflicting source tokens for the same client were flagged as a pre-publish blocker.
Rather than picking the most complete-looking script, each candidate was diffed against the canonical Internal Event schema in the agency's own guide generator, which revealed the previous merge had been built on the wrong base.
Role: Sole architect and implementer
The Problem
The client had multiple competing GTM conversion scripts in play, each posting a different payload shape for the same form_submission conversion. Consolidating on one script risked silently dropping user identifiers and conversion properties that the other script was already sending, which would degrade match quality for downstream ad platform destinations.
Two scripts posted to the Summit Chase Conversion Gateway (the Gateway) with divergent schemas: one carried the full click id sweep (URL plus cookie) but only email and phone; the other carried event_id, external_id, properties, consent, metadata and the Gravity pixel CAPI context but only gclid and fbclid. A third, older script posted to a Gravity CAPI endpoint entirely. It was initially unclear which of the scripts was canonical.
The user was uncertain which script was the correct base, and pasted the wrong one first, so an initial merge was built on an invalid schema. Resolving it required validating each candidate against the actual the Gateway Internal Event schema rather than reasoning from plausibility. Two different x-sc-source-token values for the same client appeared across the scripts, only one of which can be valid, and the fetch call swallows auth failures silently.
Approach & Architecture
Read all three candidate scripts and compared them field by field against the canonical the Gateway web/GTM template found in the internal client-integration-guide Skill generator. Established which payload shape the Gateway actually expects. Then performed an additive merge: took the user's designated base script (the one with the full click id sweep) and grafted in only the fields present in the other script, leaving the transport layer untouched. Flagged the credential conflict and two schema fields of uncertain support rather than silently resolving them.
A single GTM Custom HTML tag fires on the the client form_submission trigger. It builds one JSON payload containing user identifiers, every ad click id available from the URL query string and from first-party cookies, optional Gravity pixel CAPI context, conversion properties and consent signals, then POSTs it to the gateway Gateway browser collect route with a weak source token header. the Gateway fans the single signal out to every ad platform destination server-side, so no destination pixels or keys exist in the client's pages.
Key Decisions & Trade-offs
Hardest Part
Determining which of three near-identical-looking scripts was the canonical one after the user reversed their own designation twice. Resolved by reading the internal client-integration-guide Skill's generate_guide.py and comparing each candidate against the official web/GTM template and the FIELD_ROWS payload field table, which established that the Gateway expects the client slug in the URL path (not client_id in the body), properties (not custom_data), plus event_id and consent.
Technical Detail
the Gateway Internal Event schema for browser sources, per FIELD_ROWS in generate_guide.py: source_event_name (required), event_id (required, stable and unique per conversion, used to de-duplicate), event_time (required, ISO-8601 UTC), attribution.* (all click ids captured), user.email / phone / external_id (recommended, hashed server-side), user.ip / user_agent (recommended), properties (optional: value, currency, order_id, plan), consent (recommended: ad_user_data / ad_personalization as granted | denied | unknown). Client slug travels in the URL path, not in the body.
Google Tag Manager Web container Custom HTML tag on the client's site; the Gateway Gateway hosted at [internal-host]
No execution-level validation was performed in this chat. Verification was schema-level: the three candidate scripts were diffed against the canonical web/GTM template and FIELD_ROWS table in /mnt/skills/user/client-integration-guide/generate_guide.py. GTM Preview mode was recommended as the next check, specifically for the unquoted GTM variable tokens which would surface as a tag syntax error.
Code
var IS_GRAVITY_DESTINATION = true;
var dl = (window.dataLayer && window.dataLayer.length) ? window.dataLayer[window.dataLayer.length - 1] : {};
var fd = (dl && dl.form_data) ? dl.form_data : {};
var gravity = null;
try { if (IS_GRAVITY_DESTINATION && window.gravityPixel && typeof window.gravityPixel.getCAPIData === 'function') { gravity = window.gravityPixel.getCAPIData(); }
} catch (e) { gravity = null; }
var payload = { client_id: "the client", source_event_name: "form_submission", event_id: fd.event_id || undefined, event_time: new Date().toISOString(), page_url: document.location.href, user: { email: {{dlv - form_data.email}}, phone: {{dlv - form_data.phone}}, external_id: fd.external_id || undefined }, attribution: { gclid: pick("gclid"), gbraid: pick("gbraid"), wbraid: pick("wbraid"), fbclid: pick("fbclid"), fbc: pick("fbc", "_fbc"), fbp: pick("fbp", "_fbp"), msclkid: pick("msclkid"), ttclid: pick("ttclid"), ttp: pick("ttp", "_ttp"), rdt_cid: pick("rdt_cid"), li_fat_id: pick("li_fat_id"), utm: { source: pick("utm_source"), medium: pick("utm_medium"), campaign: pick("utm_campaign") }, gravity: gravity ? { user_data: gravity.user_data || undefined, client_context: gravity.client_context || undefined, event_source_url: gravity.event_source_url || undefined } : undefined }, properties: { value: fd.value || undefined, currency: fd.currency || undefined, form_id: fd.form_id || undefined, form_name: fd.form_name || undefined }, consent: { ad_user_data: fd.ad_user_data || 'unknown', ad_personalization: fd.ad_personalization || 'unknown' }, metadata: { source_version: 'gtm-v1', debug: false }
};var qs = new URLSearchParams(window.location.search);
function pick(param, cookie) { return qs.get(param) || (cookie ? (document.cookie.match('(^|; )' + cookie + '=([^;]+)') || [])[2] : undefined) || undefined;
}fetch("[url]]/v1/collect/the client/browser", { method: "POST", headers: { "Content-Type": "application/json", "x-sc-source-token": "1360b81ac1b6f4c44deb2348d71e70be905bb2099850087c" }, body: JSON.stringify(payload), keepalive: true
});var GATEWAY = '[url]]';
var CLIENT_ID = '{client_slug}';
var SOURCE_EVENT = 'signup';
var SOURCE_TOKEN = '{token}';
var payload = { source_event_name: SOURCE_EVENT, event_id: dl.event_id || undefined, event_time: new Date().toISOString(), page_url: window.location.href, user: { email: dl.email || undefined, phone: dl.phone || undefined, external_id: dl.external_id || undefined }, attribution: { gclid: dl.gclid, gbraid: dl.gbraid, wbraid: dl.wbraid, fbclid: dl.fbclid, fbc: dl.fbc, fbp: dl.fbp, msclkid: dl.msclkid, ttclid: dl.ttclid, ttp: dl.ttp, rdt_cid: dl.rdt_cid, li_fat_id: dl.li_fat_id }, properties: { value: dl.value, currency: dl.currency }, consent: { ad_user_data: dl.ad_user_data || 'unknown', ad_personalization: dl.ad_personalization || 'unknown' }
};
fetch(GATEWAY + '/v1/collect/' + CLIENT_ID + '/browser', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-sc-source-token': SOURCE_TOKEN }, body: JSON.stringify(payload), keepalive: true, mode: 'cors'
}).catch(function () { });Claude was used as the merge and adjudication engine rather than as a code generator. When the user could not identify which of three candidate scripts was canonical, Claude read the internal client-integration-guide Skill from the filesystem, grepped generate_guide.py for the Internal Event schema markers (source_event_name, properties, consent, x-sc-source-token, collect/), and diffed each candidate against the official web/GTM template and the FIELD_ROWS field table. That comparison, not intuition, produced the verdict. The final pass was a constrained additive merge under an explicit do-not-alter-anything-else instruction.
Measured Results
A single consolidated GTM Custom HTML tag was delivered that preserves the full click id sweep from the base script while restoring event_id, external_id, Gravity pixel context, properties, consent and metadata from the competing script, with the transport layer untouched. The adjudication step also caught that an earlier merge attempt had been built on a non-canonical schema, and surfaced a credential conflict (two different source tokens for the same client) plus two schema fields of unconfirmed support. No deployment, delivery-rate or match-quality figures were produced in this chat.