Advanced architecture
Server-side tagging
An event can leave the browser, land on your own server, and only then be shaped for GA4. This page posts to a route on this origin. The route redacts an email flag, adds the server time, and shows the payload it would forward. It does not call Google.
Example data, not real traffic.
A live forward needs a Measurement Protocol secret and a place to store the outcome. This route returns the payload and does not store it.
Understanding the labHow to use it and why you'd want to
Why you'd want to
You want the hit shaped on your server before any vendor sees it. After Accept, the page can queue a view event and the route still does not forward.
How to use it
- Pick an event and mark whether an email was present.
- Send it. Read the redacted list and the server time.
- See forwarded false on the GA4 payload.
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.
The tagging lab posts a named event to /api/advanced/collect. The route refuses the call unless consent is granted, drops personal keys, and returns a GA4-shaped payload with forwarded false.
Refuse the call without consent
collectServerSide returns consent_required and a null GA4 payload when consent is denied. The route answers 403.
Drop personal keys
email, phone, name, and address are listed in redacted and left out of the enriched object.
Build the payload and stop
The result adds server_time and transport first_party. forwarded is false because no vendor account is configured.
From the code
Consent off returns no GA4 body.
if (input.consent !== "granted") {
return { accepted: false, reason: "consent_required", redacted, enriched: {}, ga4: null }
}The route uses the same function and does not store the body.
const result = collectServerSide({ name, params, consent, now })
return NextResponse.json(result, { status: result.accepted ? 200 : 403 })Google and Adobe
Google queues advanced_lab_view after Accept. Adobe is an example of the same fields.
After Accept, this lab queues advanced_lab_view. The demo payload stays on the page. This site does not call Adobe.
Simplified shape of the object queued after Accept.
dataLayer.push({
event: "advanced_lab_view",
lab_id: "server-side-tagging",
})Example implementation. This site does not call Adobe. eVar160, prop160, and event160 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 eVar160 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: {
collectForwarded: "false",
},
},
})Example hit. eVar160 is hit-scoped in this example.
s.eVar160 = "false"
s.prop160 = "false"
s.events = "event160"
s.tl(true, "o", "advanced_lab_view")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…