async, defer or type="module": pagent needs to load before your page shows, so visitors never see the original flash.
Add the snippet to your theme
1
Open your themes
In your Shopify admin, go to Online Store → Themes.
2
Make a backup
Next to your current theme, click ⋯ → Duplicate. Shopify keeps the copy, so you can always go back.
3
Open the code editor
Next to your current theme, click ⋯ → Edit code.
4
Open theme.liquid
In the file list, open Layout → theme.liquid.
5
Paste the snippet
Find the line
<head> near the top. Paste your snippet on the next line, right after <head>.6
Save
Click Save. The change is live on your store straight away.
Tests run on your storefront pages: home, collections, products, cart and your other pages. Shopify doesn’t run your theme’s code on its checkout, so tests stop at the last step before checkout. To count the orders that follow, add the pixel below.
Check it worked
- Open your site in a private browser window, so no cached version shows.
- Back in pagent, click Check connection in the install step. If you’ve finished setup already, open Settings → Setup: it shows You are ready once pagent has received visits from your site.
- pagent loads your live site and looks for the snippet. When it finds it, you can start your first test.
Count orders and revenue
Your theme snippet can’t see Shopify’s checkout, so orders aren’t counted yet. A custom pixel reports every order to pagent, with its revenue, currency and products. It only tracks: your tests still run on your storefront.1
Copy your pixel
In pagent, go to Settings → Setup, open Shopify and click Copy. The pixel already contains your client key.
2
Add a custom pixel in Shopify
In your Shopify admin, go to Settings → Customer events and click Add custom pixel (or Add pixel). Name it
pagent.3
Paste, save and connect
Under Customer privacy, set the permission to Analytics. Paste the pixel into the code field, then click Save and Connect (or Connect pixel).
4
Create a purchase goal
In pagent, create a conversion goal with the tag
purchase. Orders arrive without it too, but you need the goal to pick them for a test.5
Check it
Place one test order and check that it shows up in pagent.
What the pixel does
What the pixel does
It loads pagent in analytics-only mode and reports each completed checkout once, even if the thank-you page is reloaded. Each order includes its revenue, currency and line items, so a goal can also target specific products.
Where your store asks visitors for cookie consent, the pixel only runs once they accept analytics. Orders from visitors who decline aren’t counted. New pixels ask for marketing consent too by default, which is why you set the permission to Analytics.