Engagement Adapter Pattern
The adapter pattern decouples analytics components from vendor-specific event APIs. Components call a generic interface and the adapter translates those calls into the vendor’s API. Storefront Next provides three built-in adapters for analytics event tracking that use Einstein, Active Data, and Data 360 (formerly Data Cloud).
| Adapter | Purpose | Config key |
|---|---|---|
| Einstein | Analytics event tracking (viewProduct, addToCart, and so on) | engagement.adapters.einstein |
| Active Data | Analytics event tracking (dwac beacon) | engagement.adapters.activeData |
| Data 360 | Salesforce Data 360 — view/impression events only | engagement.adapters.data360 |
All three implement the EngagementAdapter interface and are registered in a shared store.
A Map<string, EngagementAdapter> with functional accessors:
Adapter code is dynamically imported to stay out of the initial bundle:
The dynamic import() means that the Einstein, Active Data, and Data 360 implementation modules are code-split into a separate chunk.
Adapters are configured in config.server.ts under engagement.adapters:
If an adapter’s enabled flag is false, it isn’t registered.
Data 360 maps only view and impression events — view_page, view_product, view_search, view_category, and view_recommender. Cart, checkout, wishlist, and click events have no Data 360 mapping and ship disabled in eventToggles.
For how to provision Data 360 and connect your storefront, see Send Storefront Next Analytics Events to Data 360.
- Create
src/lib/adapters/engagement/your-adapter.tswith a factory function returningEngagementAdapter. - Register it in
src/lib/adapters/engagement/register.tsinsideinitializeEngagementAdapters(). - Add configuration under
engagement.adapters.yourAdapterinconfig.server.ts.