Browser events
Browser events track what shoppers do on your storefront and in checkout: page views, product views, add to cart, checkout steps and orders. Every Shopify store needs three pieces, whether it uses a Liquid theme, Hydrogen or a custom headless build:
The Chord analytics package,
@chordcommerce/analyticsThe Chord identifiers script
The Chord web pixel
How it works
The web pixel listens, and the analytics package sends.
The web pixel listens. Shopify only reports shopper actions, such as product views, add to cart and checkout steps, to pixels. The analytics package can't hear them on its own.
The analytics package sends. The pixel passes storefront events to the analytics package on the page. The package delivers them to Chord, runs your browser (device-mode) destinations such as Meta Pixel or GA4, and handles identity and consent.
Checkout is the exception. The analytics package can't run on Shopify-hosted checkout pages, so the pixel sends checkout events to Chord itself. It also runs your device-mode destinations inside Shopify's checkout sandbox.
The identifiers script links sessions. It saves the shopper's browser identifiers on the cart, so the server events Shopify sends later can be matched to the same shopper.
Without the pixel, Chord sees almost nothing from a Liquid store. Without the analytics package, storefront events have no way to reach Chord.
Before you start
Ask Chord for these values:
Your CDP domain and write key
Your OMS ID, store ID and tenant ID
The Chord web pixel code
Step 1: Add the analytics package
Liquid theme
In Shopify admin, go to Online Store > Themes > Edit code.
Create a new snippet called
chord.liquidand paste in the following. Replace theyour-...values with the ones Chord gave you.In
layout/theme.liquid, add the following before the closing</body>tag:
Hydrogen or headless storefront
Install and initialize the npm package by following Everyone else: Browser events. Those steps cover Hydrogen and other JavaScript frameworks. Set platform.name to shopify in the metadata.
Step 2: Add the identifiers script
The identifiers script saves the shopper's browser identifiers as attributes on the Shopify cart. Shopify includes those attributes with the order, so Chord can link server events back to the shopper's browser session. Without it, orders from Shopify arrive in Chord with no link to the browsing that led to them.
Liquid theme
Add this line to layout/theme.liquid, just before {% render 'chord' %}:
Hydrogen or headless storefront
Load the same script on your storefront pages if your framework allows it. If not, save the identifiers on the cart yourself with Shopify's cartAttributesUpdate mutation:
_cdpAnonymousId: the anonymous ID that@chordcommerce/analyticsassigned to the shopper, from the__eventn_idcookie. Required._googleClientId: the value of the_gacookie with its first six characters removed. Add it if you use Google destinations.
Add the attributes before the shopper reaches checkout, at a moment that doesn't block them, such as when the cart page loads or after a product is added.
Step 3: Add the Chord web pixel
In Shopify admin, go to Settings > Customer events.
Click Add custom pixel and name it, for example "Chord".
Under Customer privacy, set the options described in Consent.
Copy the web pixel code into the Code box.
Update the
constvariables at the very top of the code (see the settings below), then click Save.Click Connect to activate the pixel. The pixel starts tracking as soon as you connect it, so finish the settings first.
Web pixel settings
CHORD_OMS_ID,CHORD_STORE_ID,CHORD_TENANT_ID(string): IDs assigned by Chord. Each is unique to the store, and the same across every environment and source for that store.DEFAULT_LOCALE(string): the default order locale, for exampleen-US.CDP_DOMAIN(string): provided by Chord. The domain for your website source.CDP_WRITE_KEY(string): provided by Chord. The write key for your website source.STORE_DOMAIN(string): the store slug that comes before.myshopify.comin your Shopify URL.
Verify the installation
Set
debug: trueandenableLogging: truein your analytics configuration while you test. Together they check events against the tracking plan and log warnings for missing or incorrect properties to the browser console.On a storefront page, such as a product page: open your browser's developer console. You should see Chord network requests as you browse products and add to cart.
In checkout: place a test order. Checkout Started, Payment Info Entered and Order Completed should appear in Live Events in Chord.
Turn
debugandenableLoggingoff again when you're done.
Troubleshooting
Events aren't appearing in Chord
Check that the domain and write key are the same in the analytics package and the web pixel.
Check the browser console for error messages from Chord.
Make sure the web pixel's status is Connected in Settings > Customer events.
If you're testing from a region with a cookie banner, accept analytics and marketing cookies first.
Storefront events are missing (Liquid themes)
Confirm
{% render 'chord' %}is in yourtheme.liquidlayout.Check the browser console for script loading errors from jsdelivr.
Checkout events are missing
Make sure the web pixel is connected, not just saved.
Check that the credentials in the web pixel match your analytics package configuration.
Events the web pixel tracks
The pixel tracks every standard customer event Shopify gives to pixels, with no theme code. If an interaction you care about isn't listed, Shopify doesn't publish an event for it, and you track it from your theme with the analytics package.
Storefront events
The pixel passes these to the analytics package, which sends them to Chord and your device-mode destinations.
page_viewed→ apage()call, with path, URL and titleproduct_viewed→ Product Viewedcollection_viewed→ Product List Viewed, with the collection's product variantssearch_submitted→ Products Searched, with the search querycart_viewed→ Cart Viewed, only on the/cartpage (see what the pixel doesn't track)product_added_to_cart→ Product Addedproduct_removed_from_cart→ Product Removed
Checkout events
The pixel sends these to Chord itself, and runs your device-mode destinations in the checkout sandbox.
checkout_started→ Checkout Started, with line items, coupon, discount, tax and shippingcheckout_contact_info_submitted→ Checkout Step Completed (step 1), plus anidentifywith the shopper's email and phonecheckout_address_info_submitted→ Checkout Step Completed (step 2)checkout_shipping_info_submitted→ Checkout Step Completed (step 3)payment_info_submitted→ Payment Info Entered (step 4)checkout_completed→ Order Completed, plus anidentifywith the Shopify customer ID
Customer identification
The pixel sends an identify call in three situations:
On load, when Shopify reports a logged-in customer. Traits come from Shopify's customer object: email, first and last name, phone and order count.
When the shopper submits contact info in checkout, with the email and phone they entered. No user ID is set here, because an email isn't a stable identifier.
When checkout completes, with the Shopify customer ID as the user ID.
What the pixel doesn't track
Sign-in. Shopify publishes no sign-in event, so a shopper who signs in mid-session isn't identified until the next page load. To identify them right away, call window.chord.identify() from your theme when they sign in.
Cart drawers. Shopify fires cart_viewed only when a shopper goes to /cart. If your theme opens the cart in a slide-out drawer, call window.chord.trackCartViewed() when the drawer opens.
Merchandising interactions. No standard event covers clicks in a collection grid, quick-add buttons, wishlist actions or variant switching. Track these from your theme code. See the SDK reference.
Last updated
Was this helpful?