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 two built-in adapters for analytics event tracking that use Einstein and Active Data.

AdapterPurposeConfig key
EinsteinAnalytics event tracking (viewProduct, addToCart, etc.)engagement.adapters.einstein
Active DataAnalytics event tracking (dwac beacon)engagement.adapters.activeData

Both 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 or Active Data 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.

  1. Create src/lib/adapters/engagement/your-adapter.ts with a factory function returning EngagementAdapter.
  2. Register it in src/lib/adapters/engagement/register.ts inside initializeEngagementAdapters().
  3. Add configuration under engagement.adapters.yourAdapter in config.server.ts.