Personalization for your Shopify store
Installed with one script tag in theme.liquid. The recommendation card adds to the Shopify cart itself, and the basket total is read from /cart.js.
What the ready integration gives you
Selwise campaigns, recommendations, onsite search and A/B tests run on your Shopify store. The script goes into the theme’s theme.liquid file right before the closing body tag and runs on every theme page. Page type is recognized from Shopify’s standard paths (/products/, /collections/, /cart) and product views are read from the product’s JSON-LD. “Add to cart” on recommendation and search cards adds the product itself with /cart/add.js, and the goal bar reads the basket total from /cart.js. Shopify has no ready dataLayer mapping: cart events are sent from the theme code.
- Page type by the default patterns: /products/, /collections/, /cart, /checkout, /search, /account
- Product views are read from Product JSON-LD (sku first), .product-template and [data-product-handle]
- Add to cart from a card with POST /cart/add.js; the theme’s cart indicator refreshes
- The goal bar reads the basket total from GET /cart.js (amounts in cents are converted)
Checkout and order status pages do not load the theme: orders are sent from “Order status page → Additional scripts” with the install snippet first and trackOrder after it. Stores on Checkout Extensibility may not have that field; there the order is sent from the server. /cart/add.js needs a variant id: map the feed’s variant id as the “Add-to-Cart Code”.
- 1Add the script to the themeOnline Store → Themes → Edit code, in theme.liquid right before </body>.
- 2Verify the domainPress Verify Now on the channel page; it passes because the theme prints the tag on the server. store.myshopify.com is a separate domain.
- 3Turn on the data layerIn the Data Layer settings turn the data layer on and choose the Shopify preset; the goal bar that reads the cart works with the explicit choice.
- 4Add order trackingSettings → Checkout → Order status page → Additional scripts: the install snippet first, then trackOrder filled by Liquid. Amounts are divided by 100, the code is line_item.sku.
- 5Map the feed and cart codeEnter the feed URL and map its fields; put the variant id into the “Add-to-Cart Code”. For the nested-variant format, grouping has a nested option.
Where each signal comes from
What is read by itself on your Shopify store and what the theme code has to send.
| Signal | Source |
|---|---|
| Page viewAutomatic | By itself, on every page the script loads on. |
| Page typeAutomatic | From Shopify’s standard paths, by the default patterns. |
| Product viewAutomatic | From the product’s Product JSON-LD (sku first), .product-template and [data-product-handle]. |
| Basket totalAutomatic | GET /cart.js; only with the Shopify preset chosen explicitly. |
| Add and remove from cartYou send it | No ready dataLayer mapping; sent from the theme code with window.selwiseLayer.push. |
| OrderYou send it | trackOrder in the order status page’s Additional scripts; from the server on Checkout Extensibility. |
| User identityYou send it | A signed-in customer’s id is passed from the theme Liquid with Selwise.identify. |
| Search termYou send it | With Selwise search on, the search records it; for the store’s own search a search_query event is sent. |
Shopify questions
In the Shopify admin, follow Online Store → Themes → Edit code and add the Selwise snippet to theme.liquid right before the </body> tag. theme.liquid runs on every theme page; checkout and order status pages do not use the theme, so the script is added there separately.
Selwise adds the product with POST /cart/add.js and refreshes the theme’s cart indicator. The request needs a variant id: put the feed column carrying it into the “Add-to-Cart Code” row of the field mapping; otherwise the product’s own code is sent and Shopify rejects the request.
From the order status page’s Additional scripts: that page does not load the theme, so the install snippet goes first, then the trackOrder call Liquid fills with the real order. Stores on Checkout Extensibility may not have that field; there the order is sent from the server, because a Custom Pixel cannot reach the storefront’s window.Selwise.
The last-touch data in the browser cannot be read from a checkout page on a different domain. Attribution is recovered through the carrier parameter on recommendation links; do not expect campaign attribution on the order page in that case.
No; enter the URL on the Product Feed screen and map the fields. For the Shopify format that lists variants nested, variant grouping has a nested option. The code in the product view event (JSON-LD sku) must match the feed’s product code, or product reports stay empty.
