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

Setup
  1. 1Add the script to the themeOnline Store → Themes → Edit code, in theme.liquid right before </body>.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
Technical documentation →

Where each signal comes from

What is read by itself on your Shopify store and what the theme code has to send.

SignalSource
Page viewAutomaticBy itself, on every page the script loads on.
Page typeAutomaticFrom Shopify’s standard paths, by the default patterns.
Product viewAutomaticFrom the product’s Product JSON-LD (sku first), .product-template and [data-product-handle].
Basket totalAutomaticGET /cart.js; only with the Shopify preset chosen explicitly.
Add and remove from cartYou send itNo ready dataLayer mapping; sent from the theme code with window.selwiseLayer.push.
OrderYou send ittrackOrder in the order status page’s Additional scripts; from the server on Checkout Extensibility.
User identityYou send itA signed-in customer’s id is passed from the theme Liquid with Selwise.identify.
Search termYou send itWith 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.

Try it on your Shopify store

We’ll define the scope and modules together.