Home

Web Event SDK

Get Started

Web Event SDK is a client-side JavaScript library you can install in your project to start sending event data from anywhere in your application.

Please use the latest version 4.6.2. Click here for the full API reference.

1. Initialize the library in your project

Paste the HTML script tag snippet within the <head> tag of your page and initialize with your Org ID. Please be sure to use different Org IDs for test environments and production environments.

<script>
    (function (options) {
        window.SpressoSdk = window.SpressoSdk || { init: function(o) { SpressoSdk.options = o; } }
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.async = true;
        s.src = 'https://spresso-sdk-tracking-web.us-east4.prod.spresso.com/v4.6.2/spresso.sdk.tracking.web.js';
        s.onload = function() { window.SpressoSdk.init(options) }
        var x = document.getElementsByTagName('script')[0];
        x.parentNode.insertBefore(s, x);
    })({ orgId: 'YOUR_ORG_ID' });
</script>

If User ID is available, paste the HTML script tag snippet below to initialize with Org ID and User ID.

<script>
    (function (options) {
        window.SpressoSdk = window.SpressoSdk || { init: function(o) { SpressoSdk.options = o; } }
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.async = true;
        s.src = 'https://spresso-sdk-tracking-web.us-east4.prod.spresso.com/v4.6.2/spresso.sdk.tracking.web.js';
        s.onload = function() { window.SpressoSdk.init(options) }
        var x = document.getElementsByTagName('script')[0];
        x.parentNode.insertBefore(s, x);
    })({ orgId: 'YOUR_ORG_ID', userId: 'USER_ID' });
</script>

2. Send Data

Let's get started by sending event data, for example, when a user views a Product Details Page (PDP).

SpressoSdk.trackViewPDP({
    variantSku: 'some-id',
    variantName: 'Awesome Product',
    variantPrice: 1000000,
    userId: 'awesome-customer-id',
});

Click here for the full API reference.