Refresh UTMs, Cookies, and Click IDs Known to Elevar
Overview
Understanding Context in Event Attribution:
Every event captured by Elevar contains metadata that reflects the environment in which the event took place. This context includes:
- Consent values at the time of the event
- Cookies available during the event
- Click IDs for marketing attribution
This data ensures that events are sent with the correct information to marketing destinations. However, a challenge arises when the context changes without being refreshed.
The Context Refresh Challenge
Headless Websites:
In headless websites, page loads occur only once, meaning that the Elevar script is loaded only at the initial visit. Since Elevar captures context upon script initialization, any changes such as a user accepting cookies are not reflected in future events unless manually updated. This can lead to:
- Inaccurate attribution, where events retain outdated consent states.
- Misalignment between user behavior and recorded context.
- Potential data loss for marketing and analytics tools.
The Solution: Manually Refreshing Context
To prevent outdated context from affecting event attribution, developers should trigger a manual context refresh when there are significant changes, such as:
- A user accepting or rejecting cookies
- A route change in a single-page application
- Modifications to tracking parameters (e.g., click IDs)
Elevar provides a utility function to refresh context. Calling this function ensures that all subsequent events carry the most up-to-date data.
Example Use Case:
- A user lands on a product page with consent values set to "denied."
- Elevar captures the initial context and logs the page view event.
- The user accepts cookies on the same page.
- Without a manual refresh, the "Add to Cart" event will still carry the outdated "denied" consent status.
- By calling Elevar’s context refresh utility upon consent change, the new context ("granted") is applied to all subsequent events.
Implementation
Route Changes:
- Any navigation changes without a reload will ideally notify Elevar via a utility.
- This utility will update the contextual information that Elevar uses to enrich Data Layer events. The utility can be used like so:
window.ElevarInvalidateContext?.()
Updated about 5 hours ago