Events and Purchases
How the Sophi Shopify app tracks storefront events and purchases — the events it sends, the purchase pixel Sophi creates, how Shopify consent controls both, and how guest and logged-in shoppers are recognised.
Sophi uses shopper behaviour to recommend better and to show you what the assistant is worth: which chats led to carts and orders. On Shopify, the app sends the same events as the web object, with no code on your side.
Storefront events
Switch on Send storefront events to Sophi in the Sophi assistant embed (Connection). The app then sends:
| Event | When |
|---|---|
page_view | Any page |
product_view | A product page |
listing_view | A collection or search results page |
basket_view | The cart page |
add_to_cart / remove_from_cart | The cart changed — from the theme's buttons, the cart drawer or the chat |
checkout_started | The shopper went to checkout |
Cart changes are worked out by comparing the cart before and after, so a change counts once whether the theme or the chat made it.
Purchases
Shopify's checkout runs no theme code, so purchases come from a web pixel: the
sophi-pixel extension deployed with the app. When an order is completed it sends
one purchase event with the order id, totals (tax, shipping, discounts and
discount code) and the order lines, joined to the same shopper as the chat.
Web pixels have no theme-editor screen; an app creates its pixel through Shopify's Admin API. Sophi creates it for you with your app's credentials, after the app is installed. Afterwards it is listed in your admin under Settings → Customer events.
The app code includes the script Sophi uses. It reads the credentials from the
environment, never prints them, and only reports what it would do unless you pass
--apply. Running it again updates the existing pixel instead of creating a second
one.
SHOPIFY_STORE=your-store.myshopify.com \
SHOPIFY_CLIENT_ID=… SHOPIFY_CLIENT_SECRET=… \
SOPHI_API_KEY=… SOPHI_API_URL=https://api.usesophi.com \
node scripts/pixel.mjs # report only; add --apply to create itConsent
The app reads Shopify's Customer Privacy API — the choices the shopper made in your cookie banner — before it starts anything, and fails closed: if consent is unknown, it acts as if it was refused.
| Shopper allows | What happens |
|---|---|
| Nothing | The chat works, anonymously: no cookies, no customer id or name, no visited pages. No events. |
| Preferences | The chat remembers the shopper (Sophi cookies), greets a logged-in customer by name, and uses the pages they visited for context. |
| Analytics | Storefront events are sent; for them the tracker also keeps Sophi's session cookies and a cart snapshot in local storage. Shopify runs the purchase pixel (it is declared analytics-only, so Shopify itself skips it otherwise). |
One functional exception: when a shopper clicks a Sophi chip in Full page mode,
the question (and the product, from a product box) travels to the chat page in its
address (?sophi_q=…, ?sophi_product=…). The chat page asks it once, removes it
from the address, and uses a one-time token in session storage to make sure only
questions the shopper clicked are asked. Mention in your privacy notice that these
questions can appear in page addresses, like search terms do.
Consent is whatever Shopify reports for the shopper, so it follows your cookie banner and your Customer privacy settings in the Shopify admin.
Shopper identity
- Guests get an anonymous Sophi session, kept in first-party cookies on your domain (with preferences consent for the chat, or analytics consent for events). The chat, the events and the purchase pixel all share it, so a purchase is linked to the chat that led to it.
- Logged-in customers are recognised by their Shopify customer id, so they get the same chat history and memory on every device. The app sends their first and last name, and nothing else about them.
- Logging in links the guest session to the customer; their earlier guest chats move to their account. Logging out starts a new guest session.
Next: Test and go live.
Match Your Brand
Style the Sophi Shopify blocks and chat button to match your theme with the Sophi appearance app embed — corners, chip colours, icon, banner alignment, chat-button font and custom CSS — with a live demo of every setting.
Test and Go Live
Test the Sophi assistant on an unpublished Shopify theme copy with a preview link, publish it, assign the chat page template, roll back if needed, and fix the most common setup problems.