Measure sales on Shopify
Install the agent pixel in Shopify's Customer events. It reports every completed order with its conversation key, and counts the add-to-carts shoppers make on your own pages next to the agent's.
On Shopify, one pixel does the whole job. Once it is installed, every completed order on your store is reported to the agent, with the key of the conversation it followed when there is one. There is nothing else to add to your theme or your checkout. See Orders the pixel reports. The Sales report, the orders alerts and the orders linked to a conversation all rest on it. How the key and the order meet is explained in Measure your sales.
The same pixel counts add-to-carts. The agent records an add-to-cart when it puts a product in a shopper's cart. Shoppers also add products on your own pages, without the agent. The pixel counts those too, so you can compare the two and see how many adds happen in a session where the agent was involved.
You install it once, in Shopify, by pasting a short script. Without it, only the adds the agent makes are counted, and no order from your store is recorded.
Before you start
- The site's platform set to Shopify, on the Website tab of the site settings. The Track your sales card shows the pixel only on a Shopify site; on another platform it shows Google Tag Manager instead.
- Access to your Shopify admin, to add a custom pixel under Customer events.
- The Edit sites permission in the agent to change the two recording switches. Without it, you can read the code but not change them.
Install the pixel
In the agent, open the site, then Site settings > Installation. Find the Track your sales card and its Shopify custom pixel method. You can also reach it from your Shopify connector's page, through Open the install settings.
Choose Copy the pixel code. The code already carries your site key.
In your Shopify admin, choose Settings, then Customer events, then Add custom pixel. Give the pixel a name, for example "iAdvize". Paste the code in the pixel's code box, replacing anything already in it.
Under Customer privacy, set Permission to Not required and Data sale to Data collected does not qualify as data sale. Choose Save, then Connect.
![]()
Add a product to the cart on your storefront. Back in the agent, the Add-to-carts received row of the card changes from No add-to-cart received yet. to Last add-to-cart received followed by a time. Reload the Installation tab to see it.
Place an order on your storefront. After a reload, the Orders received row changes from No order received yet. to Last order received followed by a time.
Installed the pixel before? Paste the code again
The card says: Installed the pixel before? Paste this code again: earlier versions may miss orders. The oldest pixel code sends add-to-carts only and no order. Later code sends orders but reads the conversation key from the checkout's attributes only, not from the tag's cookie. Version 3 sends orders without their lines (see The order's lines). The current code, version 4, sends each add-to-cart in the item format of Google Analytics 4 (product, variant, unit price) and names itself as the Shopify pixel. The agent still accepts the add-to-carts of earlier code for now, but that older format is meant to be removed. Copy the code from the card again and replace the pixel's code in Shopify.
If you rotate the site key, the old pixel keeps sending to an address that no longer resolves to your site. Copy the new code and paste it in Shopify again.
Why the two Shopify settings matter
With Permission set to Required, a custom pixel runs only for shoppers who have consented to marketing or analytics tracking. A shopper who has not consented triggers nothing. Not required means the pixel always runs.
Data sale has three choices. Shopify's hint under each one says what it does:
- Data collected qualifies as data sale: the pixel collects nothing for a shopper who has opted out of the sale of their data.
- Data collected qualifies as data sale and supports limited data use: the pixel still collects data for that shopper.
- Data collected does not qualify as data sale: the pixel still collects data for that shopper. This is the choice to make.
⚠ What the pixel receives under Data collected qualifies as data sale and supports limited data use has not been measured. Choose Data collected does not qualify as data sale.
Two choices under-count
With Permission set to Required, or Data sale set to Data collected qualifies as data sale, the pixel still works, but it skips the shoppers who did not consent or who opted out of data sale. Your storefront count will be lower than what shoppers actually add, and the comparison with the agent's adds will tilt toward the agent. The agent cannot tell the two cases apart.
What is recorded
For each add to cart on your pages, the agent stores:
- the product id and the variant id,
- the quantity added,
- the time of the add (the time Shopify reports; if it is in the future or more than a day old, the agent uses the time it received the event),
- the shopper's device type, taken from the browser,
- the agent session key, when the shopper's browser holds one,
- what the quantity added is worth: an amount and its currency, when Shopify gives them,
- a reference to the shopper's cart: Shopify's cart token, when the pixel can read it,
- the sender (the Shopify pixel) and the version of the pixel code, sent by code from version 4 on. Nothing displays them.
The session key is the same non-identifying key the tag uses to link a shopper's events within one visit. If the tag did not run on the page, or a script blocker stopped it, the add is still counted, without a session key.
The amount is the value of the quantity added, not the cart total. The pixel sends the unit price (Shopify's total for the line added, divided by the quantity) and the agent multiplies it back by the quantity, then rounds the result once to the currency's minor units (cents for EUR or USD). Pixel code before version 4 sends the line total instead, which the agent stores as it is. The agent keeps the amount in the currency's minor units, next to the currency. It stores both or neither. If the amount is negative, too large, or the currency is not a known ISO 4217 code, the agent drops the amount and still counts the add. The cart reference is Shopify's cart token. The pixel removes the access key that follows it in the cart cookie before sending, so the key never leaves the browser. The agent also keeps only what comes before the first ? of any reference it receives, so an access key is never stored. A reference you send yourself to the same route should be a plain token without a query string.
The amounts are stored but no report shows them yet. A pixel you pasted before this change does not send the amount or the cart token. Paste the new code from the Installation tab to send them.
For an add, the pixel code reads only Shopify's add-to-cart event, the cart token, the session key and the objection flag. It does not read or send a customer field or any text of the page. What it reads for an order is in Orders the pixel reports. The agent does not store a conversation, a visitor or an order on these adds. When the counts are read, an add counts as "in a session with a conversation" if the same session key started a conversation on the same site before the add (see Add-to-cart counts).
The agent's own adds carry the same fields when its cart result gives them: the line's price times the quantity added, the currency and the cart token. When the erasure of a conversation is run, the cart reference on that conversation's adds is cleared along with the conversation, session and visitor keys. When a conversation expires on the normal retention schedule, the cart reference is kept on those adds. The adds from your pages are never tied to a conversation, so erasure does not reach them. They go on the retention schedule of the measurement data.
The data-usage notice shoppers can open from the agent lists these adds in their own bullet, with the same retention as the other measurement data, as long as counting is on.
Orders the pixel reports
When Shopify reports a checkout as completed (its checkout_completed event), the pixel sends the agent:
- the order's id, as
gid://shopify/Order/<id>, - Shopify's checkout subtotal and its currency,
- the time Shopify gives for the event (if it is in the future or more than a day old, the agent uses the time it received the order),
- the agent session key, when the shopper's browser holds one,
- the conversation key: first from the tag's cookie
iadvize_atr_<site key>(see Where the key goes), read through Shopify's cookie API for pixels; when there is none, from the checkout'siadvize_attributionattribute. A cookie value that does not have the shape of a key is not used; the checkout attribute is sent as it is. - the order's lines, described below,
- the sender (the Shopify pixel) and the version of the pixel code, from version 4 on. Nothing displays them.
Reading the cookie at checkout was checked on a live store
On 2026-12-01, on a Shopify demo store, a test copy of the pixel that reads only the cookie read the key through Shopify's pixel sandbox at checkout. The key matched the checkout attribute, and the order was recorded and linked to its conversation. The checkout attribute stays the fallback when the pixel finds no cookie.
The agent also stores the shopper's device type, taken from the browser. Safari on an iPad presents itself as a Mac and the pixel cannot tell the two apart, so an add or an order from an iPad counts as Tablet only when the tag already recorded the same session as Tablet; without that, it stays Desktop. The pixel reads no customer, address, payment, shipping or tax field, no product name or image, and no text of the page. It sends nothing for a checkout with no order id, or with no subtotal or currency. It sends no refund and no cancellation.
The order's lines
With each order, the pixel sends the products in it as a list named items, in the item format of Google Analytics 4 ecommerce events. Each line carries:
item_id: the Shopify product id, when there is one. It is Shopify's numeric id written as text (for example"15789822673244"), not agid://address,item_variant: the Shopify variant id, in the same form,quantity: the quantity ordered,price: the unit price paid, after the line's discounts (the line's total divided by its quantity, not rounded),discount: the discount per unit, only when the line's discount is at least half a cent,sku: the variant's SKU, only when it has one of at most 100 characters. A longer SKU is left out, never cut.
The amounts are in the order's currency. When Shopify gives no total for a line, the pixel sends the variant's catalog price and no discount. A line with no variant id, no whole quantity above zero or no catalog price is left out, and the rest of the order is sent.
The lines never stop an order from being sent. The pixel sends at most 100 lines: the first 100 usable lines of the checkout, a skipped line not counting. If the order with its lines is too large for the endpoint (32,768 bytes), or reading the lines fails, the order goes without them.
The agent does not use the lines yet
The agent receives the lines but does not store them, and no report, page, API
or MCP tool shows them. The pixel sends them now so that a later use of them
does not need you to paste its code again. The line fields and the id format
were checked on a live Shopify store on 2026-12-01, on an order with no
discount: price matched the order's subtotal, so it is on the same tax basis
as the order's amount. ⚠ A line with a discount, and a store that shows prices
without tax, have not been measured.
The orders go to the same public endpoint described in Send orders from a server, so the same rules apply: one answer whatever happens, the same rate limits, and nothing recorded when Record orders from your store is off for the site.
Limits of the orders the pixel reports
The pixel sees the checkout from the shopper's browser, not the order in your Shopify admin. For every order it reports:
- The amount is Shopify's checkout subtotal. It is after discounts and before shipping. On a store that shows prices with tax, it includes tax, so revenue reads higher than the same orders without tax.
- Test orders are not recognised. The pixel cannot see Shopify's test flag, so a test order counts as a real sale.
- Payment is not checked. The pixel reports the completed checkout, not the payment. An order whose payment never completes still counts. ⚠ Whether Shopify fires the event for an order awaiting a manual payment (bank transfer, cash on delivery) has not been measured.
- Orders from the agent's checkout link may not be linked to their conversation. Such an order carries its key in the landing page address, which the pixel does not read. It is linked only when the pixel finds the key in the tag's cookie, that is when the shopper chatted on your site in the same browser (checked on a live store, see above). An order from your AI Storefront has no cookie on your store's domain, so it counts for the site, not for the agent. Orders from your store's own cart carry the key as an attribute and are linked.
- Order lines are not used. The pixel sends them, but the agent does not store them yet. Every figure rests on the order total.
- No refunds or cancellations. The agent records neither, from any source. An order refunded or cancelled later keeps counting at its full amount.
How an order gets its key
On Shopify, a conversation's key can travel three ways. The pixel reads the first two, the cookie before the cart attribute. It does not read the third.
- The tag's cookie. On every platform, the tag keeps the key in the cookie
iadvize_atr_<site key>on your store's domain (see Where the key goes). The pixel reads it first. - Your store's own cart. On a page where Shopify's storefront script runs, the tag also sets the key as the cart attribute
iadvize_attribution, from the shopper's browser, when the agent's reply to a message reaches the page. An order checked out from that cart carries the attribute, and the pixel reads it when there is no cookie. A headless storefront that does not accept the tag's cart update is not tagged. - The agent's cart. When the agent creates or updates a cart, it puts the key in the cart's attribution field with the tag
iadvize_attribution. On your site's web tag, the agent usually works on your store's own cart (see The shopper's own cart on Shopify), so this is the same cart. A separate agent cart remains on the AI Storefront and on a turn where the store's cart could not be used. An order placed from the checkout link the agent gives for that cart carries the key in its landing page address, which the pixel does not read.
If a cart was last written for conversation A and then for conversation B, it carries B's key afterwards.
What you will see
- On carts and orders in Shopify, the
iadvize_attributionattribute, on orders from your store's cart. - In your marketing reports, for orders from the agent's checkout link. Shopify replaces the order's landing page with a link carrying the tag. The campaign (UTM) parameters from the page the shopper first arrived on are replaced with it, in Shopify's own reports. Shopify does not document this. We saw it on test orders on a development store. The agent adds no campaign parameter of its own.
- Orders from your store's own cart keep their landing page and UTMs. This was measured too.
When a shopper objects
A shopper who objects to measurement is not counted. The pixel reads the tag's objection flag, and when it is set to 1 it sends nothing, neither the add nor the order. The tag also deletes the key cookie, and removes the key from the store's cart when it tagged that cart on the same page. The agent also drops any add or order that arrives marked as objected, so a pixel modified to ignore the flag changes nothing on the server side.
The pixel reads the session key and the objection flag from the same browser storage the tag writes them to. For add-to-carts, this was checked on a live Shopify store, from the pixel's sandbox. ⚠ For orders it has not been measured. The pixel checks the flag on the order confirmation page too, but a store can serve that page on another domain, where the tag's storage may not be readable. If the pixel reads nothing there, it sends the order with no objection, along with the session key if it found one.
Switch the counting off for a site
Adds and orders have a switch each, both on by default, in the Sales measurement card of Site settings > Site access. Turn one off and click Save.
- Count add-to-carts on your pages: off, the pixel's add-to-carts are no longer recorded. Orders keep being recorded. The adds the agent makes in a conversation stay counted.
- Record orders from your store: off, no new order from your store is recorded, and conversations on your site get no key, so no cookie is written and no cart is tagged. Add-to-carts keep being counted. Assisted revenue, the agent's conversion rate and agent A/B tests on purchases stay empty from then on.
With both off, the pixel keeps running in Shopify without effect. You can remove it in Shopify too.
Switching off does not delete what was already recorded; it is removed on the normal retention schedule. See The two switches.
Both are also available over the API (storefrontCartCountingEnabled and storefrontOrderCountingEnabled on Update a site) and in the MCP server (set_site_automation).
What can go wrong
- Adds arrive, but no order. The pixel code in Shopify is an earlier version, or Record orders from your store is off. Copy the code from the card again and replace it in Shopify, and check the switch.
- No add received after a test. The pixel is not connected, Permission is not Not required, or the shopper has not consented while Permission still requires it. Check the pixel's status in Shopify's Customer events.
- The count looks low. See the two Shopify settings above.
- Counting is on but nothing is recorded. Check the switch that matches what is missing: adds and orders each have their own. The page also answers the pixel the same way whether it recorded or not, so the answer never tells you.
- A very high rate of events from one address. The endpoint limits requests per IP address and per organization. Events over the limit are dropped.
- Not Shopify. The pixel is Shopify only. On another platform, report orders with the transaction command and add-to-carts with the addToCart command.
To check when the latest add and the latest order reached the agent without opening the dashboard, read the site's storefront activity: Get a site's storefront activity in the REST API or get_storefront_activity in the MCP server. They return the same times as the card.
To read the counts, see get_report with add_to_cart or Get a site's add-to-cart counts.
Connect your Shopify store
Create the Shopify connector from your store domain, so the agent can search your catalog, read your shop policies and work on the shopper's cart.
The shopper's own cart on Shopify
On a Shopify store with the web tag, the agent adds to and reads the cart behind your store's cart icon, and the tag refreshes the cart count on the page. What the shopper sees, what the tag does, and what stays separate.