Next Commerce

Event Tracking

Apps can install an Event Tracker to add storefront ecommerce Event Tracking as part of their integration.

An installed event tracker simplifies the setup flow and makes the app easier for merchants to use, with fewer manual setup steps and simple dashboard configuration.

Event trackers and App snippets are not cross compatible as Event Trackers are loaded in their own sandboxed environment for greater security.

Add Event Tracker to Manifest

When building your app, map a javascript file to be installed as an Event Tracker.

Example Storefront Event Tracker
"storefront_event_tracker": "tracking.js",
"settings_schema": [
     {
        "name": "custom_app_id_enabled",
        "type": "checkbox",
        "label": "Enable Custom App",
        "help_text": "",
        "default": false
     },
    {
        "name": "custom_app_id",
        "type": "text",
        "label": "Example Text Setting",
        "default": "",
        "required": 1,
        "help_text": "",
        "max_length": 250
    }
  ]

When your app is installed, an event tracker will be automatically created with the contents of the JavaScript file mapped to the storefront_event_tracker key in your manifest.json.

Access App Settings Inside Event Tracker

Apps also have Settings that can be used to control how the app works, such as enabling or disabling functionality or adding an ID for the tracking script.

Access the settings keys in your event tracker to read configuration variables in your JavaScript.

Example Settings Usage in Snippet
// access your app settings through app.settings.<settings name>

if (app.settings.custom_app_id_enabled) {
    console.log(app.settings.custom_app_id);
}

To see a full example of the features available with App Snippets, Assets, and Settings, take a look at the Google Tag Manager app on Github. View Google Analytics App on Github

On this page