Skip to main content

Shopify Pixel Setup

C
Written by Caitlin Hyer
Updated yesterday

Introduction

This guide explains how to configure your Shopify Customer Events with an OddBytes Postback pixel to track conversions back into the OddBytes Platform (OBP).

Overview

For OBP conversion tracking to work on Shopify, two things must be in place:

  1. The Creative URL must include token={token} and pass it through to the Shopify landing page.

  2. A custom pixel must be added in Shopify Customer Events with two listeners:

  • One listener to capture and store the token on page view

  • One listener to send the conversion request when checkout is completed

UTM parameters are optional and are not used for OBP matching. They are only useful if you want to review campaign traffic inside Shopify Reports.

Step 1: Add the token parameter to your Creative URL

The Creative URL must include token={token} as a dedicated parameter.

Correct format:

Example with UTM parameters:

The important part is that token={token} is present and reaches the final Shopify page. OBP matching depends on that token.

Step 2: Add the custom pixel in Shopify

  1. Log in to Shopify Admin.

  2. Go to 'Settings' β†’ 'Customer Events'.

  3. Click 'Add custom pixel'.

  4. Paste the code below into the code editor.

  5. Replace the advertiser ID in the fetch URL.

  6. Save and connect the pixel.

Pixel code

analytics.subscribe("page_viewed", async (event) => {

const qs = event.context?.document?.location?.search || "";

const clickId = new URLSearchParams(qs).get("token");

if (clickId) {

await browser.cookie.set("obp_token",

clickId + "; Path=/; SameSite=Lax");

}

});

analytics.subscribe("checkout_completed", async (event) => {

const amount = event.data?.checkout?.totalPrice?.amount;

const cid = await browser.cookie.get("obp_token");

try {

await fetch(

?id=ADVERTISER_ID_FROM_TRACKING

&value=0&token=" + cid,

{ method: "GET", keepalive: true }

);

} catch (e) {}

});

What to replace: Replace ADVERTISER_ID_FROM_TRACKING with the OBP tracking ID that you are using to track the conversions.

⚠ What not to change: Do not replace the token with a UTM field. The pixel must read the token from the dedicated token URL parameter and send it exactly as shown.

Step 3: How the setup works

  1. A user clicks an ad that contains token={token}.

  2. When the Shopify page loads, the page_viewed listener reads the token from the URL.

  3. The token is stored in a cookie named obp_token.

  4. When the purchase is completed, the checkout_completed listener reads that cookie.

  5. The pixel sends a conversion request to OBP through conversionpx.com.

Step 4: UTM parameters and Shopify reporting

UTM parameters do not affect OBP conversion matching. They can still be used if the advertiser wants campaign reporting inside Shopify.

Where to view them in Shopify

Go to 'Analytics' β†’ 'Reports' and open 'Sessions' attributed to marketing campaigns. Useful dimensions include:

  • utm_source

  • utm_medium

  • utm_campaign

  • utm_term

  • utm_content

Do not build the OBP pixel around a UTM parameter such as utm_medium. For OBP, only the dedicated token={token} parameter is required.

Step 5: Validation and testing

Before launch

  • Confirm the creative URL contains token={token}.

  • Open the landing page with a test value, for example:

  • Confirm the token is registered on the Shopify page and stored in the cookie.

  • Confirm the custom pixel is saved and connected in 'Shopify Customer Events'.

On the OBP side

  • Use the 'Run Pixel Test' option in 'Tracking Manager'.

  • If the test returns OK, the placed pixel is valid.

  • Even if the pixel is installed correctly, conversions cannot be matched unless there is an active creative using a URL with token={token}.

Common mistakes to avoid

  • Missing token={token} in the Creative URL

  • Adding the token only inside a UTM field and not as a dedicated token parameter

  • Changing the fetch URL to use something like token={utm_medium}

  • Expecting the setup to work before a creative is live

  • Using a global header snippet instead of Shopify Customer Events when a Shopify-native setup is available

Did this answer your question?