iAdvizeDocs

Count add-to-carts and orders on your Shopify store

Install the AISA pixel in Shopify's Customer events so the add-to-carts shoppers make on your own pages are counted next to the assistant's, and your completed orders reach AISA.

The assistant records an add-to-cart when it puts a product in a shopper's Shopify cart. Shoppers also add products on your own pages, without the assistant. The AISA pixel counts those too, so you can compare the two and see how many adds happen in a session where the assistant was involved.

The pixel also reports each completed order to AISA, so the Sales report has orders to work with even if you never set up the Shopify order webhooks. When you have both, the webhooks' figures are used. See Orders the pixel reports.

You install it once, in Shopify, by pasting a short script. It is optional: without it, only the adds the assistant makes are counted, and orders reach AISA only through the webhooks.

Before you start

  • A Shopify connector attached to the site. The pixel card only shows on the Installation tab of a site that has one.
  • Access to your Shopify admin, to add a custom pixel under Customer events.
  • The Edit sites permission in AISA to switch the counting on or off. Without it, you can read the code but not change the switch.

Install the pixel

In AISA, open the site, then Site settings > Installation. Find the Shopify pixel for add-to-carts and orders card. You can also reach it from your Shopify connector's page, through Open the install settings.

Choose the copy button on the code block. The code already carries your site key.

In Shopify admin, go to Settings > Customer events and add a custom pixel. Paste the code as the pixel's code.

Set Permission to Not required and turn Data sale off. Then save and connect the pixel.

Add a product to the cart on your storefront. Back in AISA, the line No add-to-cart received yet. changes 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 card's last line changes from No order received yet. to Last order received followed by a time.

Installed the pixel before? Paste the code again

Pixel code copied before orders were added reports add-to-carts only. It keeps working for adds, but sends no order. Copy the code from the card again and replace the pixel's code in Shopify. The card says so too.

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 Shopify's default settings, a custom pixel runs only for shoppers who have consented to marketing or analytics tracking. A shopper who has not consented triggers nothing. The count then covers only part of your real adds and stays low.

Skipping the settings under-counts

If you leave Permission and Data sale on their defaults, the pixel still works, but only for shoppers who consented. Your storefront count will be lower than what shoppers actually add, and the comparison with the assistant's adds will tilt toward the assistant. AISA cannot tell the two cases apart.

What is recorded

For each add to cart on your pages, AISA 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, AISA uses the time it received the event),
  • the shopper's device type, taken from the browser,
  • the AISA 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 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 line's total for the quantity added, not the unit price and not the cart total. AISA keeps it in the currency's minor units (cents for EUR or USD), 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, AISA 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. AISA 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. AISA 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 assistant'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 assistant 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 AISA:

  • the order's id, in the same form the webhooks use, so both name the same order,
  • 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, AISA uses the time it received the order),
  • the AISA session key, when the shopper's browser holds one,
  • the conversation key (iadvize_attribution), when it is one of the checkout's attributes.

AISA 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, tax or line field, 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 orders go to the same public endpoint described in Send orders from another platform, so the same rules apply: one answer whatever happens, the same rate limits, and nothing recorded when counting is switched off for the site.

When the webhooks report the same order

If you also set up the Shopify order webhooks, most orders reach AISA twice. AISA keeps both reports and counts the order once. Its figures come from the webhook: the amount, the time, the test flag. The pixel's figures are used only for an order no webhook reported, for example one Shopify failed to deliver. The order arriving first does not matter. If the webhook's order has no conversation key and the pixel's has one, the pixel's key is used.

Limits of an order only the pixel reported

The webhooks carry more than the pixel can see. For an order that reached AISA through the pixel alone:

  • 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, while a webhook's amount excludes it. On such a store, revenue from pixel-only orders reads higher than the same orders would through the webhooks.
  • Test orders are not recognised. The pixel cannot see Shopify's test flag, so a test order placed on a store with no webhooks 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 assistant's cart are not linked to their conversation. The pixel reads the conversation key from the checkout's attributes only. An order placed from the assistant's checkout link carries its key in the landing page address instead, which the pixel does not read (see The conversation join key). Such an order counts for the site, not for the assistant. Orders from your store's own cart carry the key as an attribute and are linked.
  • No lines, refunds or cancellations. The pixel sends the order total only. A refund or a cancellation made later never reaches AISA through the pixel.

Setting up the webhooks removes all of these limits for the orders they deliver.

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. AISA 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

Counting is on by default for every site. To switch it off, open Site settings > Site access and turn off Count add-to-carts on your pages. Click Save. From then on AISA writes nothing more for the site from the pixel, neither adds nor orders, and the pixel keeps running in Shopify without effect. You can remove it in Shopify too.

Switching it off does not delete adds or orders already recorded; adds are removed on the normal retention schedule. It does not touch the adds the assistant makes in a conversation, which stay counted, or the orders the webhooks deliver.

The switch is also available over the API (storefrontCartCountingEnabled 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 the earlier version. Copy the code from the card again and replace it in Shopify.
  • 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. A site that has the switch off records nothing. 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 and the assistant's own cart write are Shopify only. A site without a Shopify connector has no add-to-cart counts.

To check when the latest add and the latest order reached AISA 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.

On this page