Personyze Wiki Personyze Wiki docs
Open Personyze
Docs/ Feeds & Uploads/ Tracking Shopify E-commerce Events with Personyze
Feeds & Uploads

Tracking Shopify E-commerce Events with Personyze

To report Shopify e-commerce activity such as product views, cart interactions, and purchases to Personyze, follow the steps below to embed the required JavaScript code into your site. Step 1: Initialize the Personyze Tracking…

2 min read Updated 1 week ago
Using the Personyze Shopify app? You may not need this. The app embeds the tracking code in your theme for you and syncs your product catalog automatically — see Install Personyze on a Shopify store. The code below is for reporting events from Shopify’s Customer Events sandbox (checkout and the cart extension), which runs separately from your theme, or for stores that are not using the app.
To report Shopify e-commerce activity such as product views, cart interactions, and purchases to Personyze, follow the steps below to embed the required JavaScript code into your site.

Step 1: Initialize the Personyze Tracking Pixel

Insert the following JavaScript snippet in your site’s global header (before the closing </head> tag). This loads the Personyze SDK and initializes it for your account:
window._S_T || function(s)
{
    s.async = true;
    s.src = '//counter.personyze.com/stat-track-lib.js';
    s.onload = function()
    {
        _S_T.async = true;
        _S_T.setup(YOUR-ACCOUNT-ID, "*.yourdomain.com");
    };
    (document.querySelector('head') || document.documentElement).appendChild(s);
}(document.createElement('script'));

Step 2: Subscribe to E-commerce Events

Use the Shopify analytics.subscribe API to capture key customer actions and forward them to Personyze. Below are examples of how to report each event type:

Product Viewed

analytics.subscribe(
    "product_viewed",
    event => {
        if (event?.data?.productVariant) {
            console.log("Event data ", event.data);
            (self.personyze = self.personyze || []).push([
                'Product Viewed',
                event.data.productVariant.id
            ]);
        }
    }
);

Product Added to Cart

analytics.subscribe(
    "product_added_to_cart",
    event => {
        if (event?.data?.cartLine) {
            console.log("Event data ", event.data);
            (self.personyze = self.personyze || []).push([
                'Product Added to cart',
                event.data.cartLine.merchandise.id,
                'quantity',
                event.data.cartLine.quantity
            ]);
        }
    }
);

Product Removed from Cart

analytics.subscribe(
    "product_removed_from_cart",
    event => {
        console.log("Event data ", event.data);
        (self.personyze = self.personyze || []).push([
            'Product Removed from cart',
            event.data.cartLine.merchandise.id,
            'quantity',
            event.data.cartLine.quantity
        ]);
    }
);

Checkout Completed

analytics.subscribe(
    "checkout_completed",
    event => {
        console.log("Event data ", event.data);
        (self.personyze = self.personyze || []).push([
            'Products Purchased'
        ]);
    }
);
Once these scripts are embedded, Personyze will automatically receive real-time event data, allowing it to personalize content, track conversions, and generate analytics for your e-commerce funnel. 📌 Tip: Always test events using your browser’s console and verify tracking in the Personyze simulator.
Did this page answer your question?
Thank you — that goes to whoever maintains this page.