Session
{
"id": "session-0042",
"timestamp": "2024-01-01T12:00:00Z",
"source": "organic"
} Analytics Lab / Data layer
A unified data layer defines each event once, in a vendor-neutral schema. Tag Manager or a mapping script
translates that event into GA4, Adobe Analytics, Meta, and other vendor calls. This page uses GA4
recommended event names and the GA4 items array as the canonical shape. Use the controls to
see what each interaction pushes to window.dataLayer.
Session, user, and page objects are set once per page load. Every event includes them, so each vendor mapping reads the same values.
{
"id": "session-0042",
"timestamp": "2024-01-01T12:00:00Z",
"source": "organic"
} {
"auth_state": "anonymous",
"persona": "analyst",
"account_tier": "free"
} {
"template": "lab-sandbox",
"section": "analytics",
"language": "en-US"
}
Buttons, links, and forms declare their event in data-udl-* attributes. A script reads the
attributes and pushes one event per interaction.
Calls to action, help links, and site search.
Add to cart, checkout, and purchase share one items array. Each ecommerce push is preceded
by { ecommerce: null } to clear the previous event's items.
Content ratings, consent changes, and client-side errors.
Each canonical event maps to one call per vendor. Keep the mapping in Tag Manager or in one script, not in page code.
| Data layer event | GA4 | Adobe Analytics | Meta Pixel |
|---|---|---|---|
| page_view | page_view | s.t() | PageView |
| search | search (search_term) | s.tl() with an internal search eVar | Search (search_string) |
| video_start, video_progress | video_start, video_progress | Media Analytics trackPlay, milestones | Custom event |
| file_download | file_download | s.tl(this, 'd', name) | Not sent |
| add_to_cart | add_to_cart (items) | scAdd with s.products | AddToCart (content_ids, value, currency) |
| begin_checkout | begin_checkout | scCheckout | InitiateCheckout |
| purchase | purchase (transaction_id) | purchase with s.purchaseID | Purchase (value, currency) |
| consent_update | gtag('consent', 'update') | Opt-in service | fbq('consent', 'grant' or 'revoke') |
Create the data layer and push the base context before the tag manager loads and before any interaction handlers run.
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
schema: 'unified-data-layer/v2',
session: {/* ... */},
user: {/* ... */},
page: {/* ... */}
});
</script>