Edit in GitHubLog an issue
Adobe Commerce only. Learn more

Adobe Commerce Events SDK

This package serves as the foundation for eventing on an Adobe Commerce storefront. It provides access to a common data layer, and an event publishing and subscription service. You can use the Adobe Commerce Event Collector package to listen for the events and send them to Adobe Commerce for processing.

Installation

This SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on cdn, and the bundled version is hosted on npm.

To load the SDK as a script, use the following snippet.

Copied to your clipboard
<script src="https://cdn.jsdelivr.net/npm/@adobe/magento-storefront-events-sdk@1/dist/index.js"></script>

To install the script as a dependency, run this command.

Copied to your clipboard
npm install @adobe/magento-storefront-events-sdk

Confirm SDK is Available

If you used the CDN to install the script, you need to confirm the SDK asset has downloaded successfully. You can check if the download was successful by running the following code:

Copied to your clipboard
//Module Load
import mse from "@adobe/magento-storefront-events-sdk";
if(!mse) return;
//AMD Load
require(['magentoStorefrontEvents'], function (magentoStorefrontEvents) {
if(!magentoStorefrontEvents) return;

[!NOTE]

To avoid any issues, make sure you keep the script or bundled version up to date with the latest release.

Quick Start

Once imported, you have access to the four main functions of the Events SDK.

The following code example shows how to get started.

Copied to your clipboard
import mse from "@adobe/magento-storefront-events-sdk";
// subscribe to events
mse.subscribe.pageView(pageViewHandler);
// set context data
mse.context.setPage(/* page context */);
// publish events
mse.publish.pageView();
// unsubscribe from events
mse.unsubscribe.pageView(pageViewHandler);

Support

If you have any questions or encounter any issues, reach out here:

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.