Real-World Example: Enriching VIP Enrollment
In the Custom Events guide, we created avip_enrollment event that fires when a customer joins your VIP program. Now let’s enrich that event with additional context from the checkout session.
Using a GTM Custom HTML tag, you can add the customer’s VIP status from your platform’s session data:
- Using Ollie Session
- Using Platform Session (VTEX)
Available Session Objects
Ollie Shop exposes two global objects with checkout session data. For a complete reference with full examples, see the Session documentation.| Object | Description |
|---|---|
window.__CHECKOUT_SESSION__ | Ollie Shop’s normalized session data |
window.__RAW_CHECKOUT_SESSION__ | Raw platform session (VTEX, Shopify, etc.) |
Common Use Cases
User Segmentation
Enrich events with user attributes for better segmentation in analytics:Platform-Specific Data
Access raw platform data when you need fields not available in the normalized session:Setting Up in GTM
Create a Custom HTML Tag
In GTM, go to Tags > New > Tag Configuration > Custom HTML. Paste your enrichment script.
Set the Trigger
Configure the tag to fire on the appropriate trigger—for the VIP enrollment example, use a Custom Event trigger matching
vip_enrollment.Test in Preview Mode
Use GTM Preview mode to verify your enriched events are pushing correctly to the
dataLayer.Best Practices
- Always use fallbacks — Use
|| {}and|| falseto prevent errors if session objects aren’t loaded yet - Keep scripts lightweight — GTM Custom HTML runs synchronously; complex logic can impact checkout performance
- Use descriptive event names — Suffix enriched events (e.g.,
*_enriched) to distinguish them from the original events - Test thoroughly — Session data availability may vary depending on checkout stage
Further Reading
- Session Objects Reference — Full session structure and examples
- useCheckoutSession Hook — Access session data in components
- GTM Custom HTML Tags
- GTM Preview Mode