Advanced architecture
dataLayer contracts
A dataLayer push is a contract, not a free-form bag. Pick an event, edit the JSON, and the page checks required fields, types, and keys that should never be on the hit. Violations show in red. The JSON stays in this tab.
Understanding the labHow to use it and why you'd want to
Why you'd want to
You want a bad payload caught before it becomes a hit. Edit the JSON, read the red rows, and leave the payload unpushed.
How to use it
- Pick page_view, add_to_cart, or purchase.
- Break a type or add an email key.
- Read each red violation in the panel.
Loading the lab…
WalkthroughHow we built itShowHide
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
validateContract checks a JSON object against a named contract. Missing required fields, wrong types, and forbidden keys become violation rows. The lab does not push the payload.
Reject an unknown name
A name outside page_view, add_to_cart, and purchase is one violation.
Check types and required keys
value must be a number on the commerce events. An empty required field is a violation.
Flag personal keys
email, phone, and name are forbidden. The panel paints those rows red.
From the code
Forbidden keys are violations even when the rest is valid.
for (const key of contract.forbidden) {
if (key in record) violations.push({ path: key, message: "This key is not allowed on the hit." })
}The panel lists every violation in red.
violations.map((item) => <li className="text-destructive">{item.path}: {item.message}</li>)Google and Adobe
This lab does not queue its own event. The Google block is an example. Adobe is an example too.
This lab does not queue an analytics event of its own. The push below is an example, not a call this page makes. This site does not call Adobe.
Example only. This page does not push this object.
// Example only. This lab does not queue this event.
dataLayer.push({
event: "datalayer_contracts_example",
lab_id: "datalayer-contracts",
})Example implementation. This site does not call Adobe. eVar163, prop163, and event163 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar163 with Most Recent allocation and expire it on the hit.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
contractOk: "false",
},
},
})Example hit. eVar163 is hit-scoped in this example.
s.eVar163 = "false"
s.prop163 = "false"
s.events = "event163"
s.tl(true, "o", "datalayer-contracts_example")Translation
Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Lab id
GA4. Parameter lab_id on advanced_lab_view.
Adobe. Example eVar, expire on the hit.
Scope. Event. It names this lab, not the user.
Demo value
GA4. Not sent. Scores, proofs, and payloads stay on the page.
Adobe. Example prop. Do not copy the demo value.
Scope. Local state. It is not a user property.
Example counts
GA4. Not sent. Labeled example data is not a metric.
Adobe. Example event. Not sent.
Scope. A figure on the page, not a hit.
Consent
GA4. The view event is skipped until Accept.
Adobe. Example: skip the hit while consent is off.
Scope. A gate on the hit.
Recommended next
Why these picksReading path transitions…