Shopping assistant

/script/agent/v2/widget.js adds the AI stylist to your store. It puts a launcher button at the bottom right of every page, and the button opens the chat. The chat is a panel beside the page on desktop and a drawer from the bottom on a phone.

html
<script>
  window.StylorConfig = Object.assign({
    "publicKey": "sgpt-pk-…"
  }, window.StylorConfig || {});
</script>
<!-- the page bridge from your snippet goes here -->
<script src="https://stylor.ai/script/agent/v2/widget.js" defer></script>

Copy the full snippet, page bridge included, from the dashboard. See Adding Stylor to your store.

Options

Set these on window.StylorConfig.

Option Type Default What it does
publicKey string Required Your organization's public key (sgpt-pk-…). Without it nothing loads, and the console says [Stylor] StylorConfig.publicKey is required.
themeId string The theme changed most recently Which saved theme the assistant wears. Use "none" for Stylor's default look. See Themes and appearance.
datasetIds string[] or comma-separated string Worked out from the page The datasets the assistant searches. Set, it searches exactly these (drafts included, archived left out) on every page. Unset, it matches the store the shopper is on (see below).
thinking string Your organization's setting How much the assistant reasons before it replies ("none", "low", "medium", "high", where the model supports them). It overrides the setting under Organization settings → Advanced: AI models for this embed. More thinking answers more carefully, but every reply starts later. An unsupported value makes the chat fail, so leave it unset unless you are testing.
matchStoreFonts boolean true Whether the assistant uses your store's main text font. Set false to keep Stylor's own font. See Fonts.
baseUrl string https://stylor.ai The Stylor origin. Leave it unset on your storefront.

Example: one catalogue on every page

html
<script>
  window.StylorConfig = Object.assign({
    "publicKey": "sgpt-pk-…",
    "themeId": "4f1c…",
    "datasetIds": ["8b2e…"]
  }, window.StylorConfig || {});
</script>

Setting options from your theme

The snippet keeps values that are already on the page, so you can set an option in an earlier script, for example from Liquid:

liquid
<script>
  window.StylorConfig = { "themeId": {{ settings.stylor_theme | json }} };
</script>
<!-- then the snippet -->

The merge is shallow, and the first value set wins. If you paste a second snippet, it can't change a themeId the first one already set.

What it reads from your page

You don't configure these. The assistant reads them itself:

From Used for
The page's address and Shopify.shop Which of your stores the shopper is on, when datasetIds is not set.
Shopify.country Prices in the shopper's country. See Prices in the shopper's country.
Whether the page is a product page On a product page, the assistant knows the product the shopper is looking at, through the page bridge.
Your store's fonts The chat uses the font most of your page's text is set in, whatever the theme. Not read when matchStoreFonts is false.
Shopify's customer privacy consent A visitor id for analytics is kept only when the shopper has allowed analytics.
Your store's cart (/cart.js) and its cookie Your Analytics: what carts hold, how they change, and whether a shopper who left for checkout placed an order.
The signed-in customer's number Only when the shopper has allowed analytics. Kept as a one-way code, never the number, so one shopper's visits from several devices count as one person's.

When it appears

  1. The script runs once the page's HTML has been read. It checks with Stylor that the assistant can run here, and then shows the launcher.
  2. The chat itself loads only after your page has finished loading, or straight away if the shopper clicks the launcher first. It never delays your storefront.

The launcher does not appear when:

  • no active dataset is in scope (connect a store, or check datasetIds);
  • your plan doesn't include the assistant, or this period's allowance is used up;
  • the key is wrong, deactivated, or not allowed on this website.

The first two are the normal "not ready" answer and are silent by design. See Troubleshooting to find out which one it is.

Offering help first

By default the assistant waits for a shopper to open it. Switch on Offer help first in your organization's settings (Settings → Your store) and it also offers help on your pages when it notices something it can help with: a product with no size picked, a tap on a sold-out size, something just added to the cart, a product the shopper has come back to. The offer is one short prompt by the launcher or beside your size guide link, and a tap opens the chat with the assistant already on the subject.

You don't add anything to your theme. The same snippet loads it, and switching it off takes effect on the next page view. It shows at most one prompt a page and three a visit, and stops for the visit once a shopper closes one.

It works on Shopify stores, on pages shown in English. You can also switch it with the API: PATCH /v1/widget/settings with moments: true.

The page bridge

The bridge is the second <script> in your snippet. The chat runs in an iframe on stylor.ai, so on its own it can't touch your page. The bridge listens for requests from that iframe only, checked by origin, and runs them in your page:

  • reading the cart (/cart.js);
  • adding, changing and removing cart lines, when the shopper asks;
  • reading the product on a product page (/products/<handle>.js).

The bridge works with Shopify's cart. Without it (an old snippet, or one with the bridge removed), the assistant still chats and styles, but it can't see the cart or the page, and it never offers to add to the cart. Nothing errors.

See it on you

Shoppers can add a photo of themselves, by uploading one or taking one with the camera, and see a look worn by them. The photo stays in their own browser and is never stored by Stylor.

You can turn it off for one store in that dataset's Styling tab, or for every store under Organization settings → See it on you. It shows only where both allow it.

Try it on, on your product photos

Switch on Try it on, on product photos in your organization's settings (Settings → Your store) and a small "Try it on" button sits on the photo on your product pages, in your theme's button colour. A tap opens a small card out of the button, drawn in your page: not the chat, and not a window. Your product photo stays as it is. A shopper who has used it before sees the product on their photo in the card straight away. The first time, the card says what a photo is used for and asks for one. Only that one piece changes in their photo: the rest of what they are wearing stays. The card stays open while they pick a size or add to the cart, and closes with its own button or a second tap. Their photo is kept in their own browser, on your store's site, for 30 days from its last use, and they can change or remove it from the card. It is separate from a photo they give the assistant in the chat.

You don't add anything to your theme, and nothing is put inside your gallery: the button is laid over the photo and follows it. It goes in a corner of the photo that is on screen and free of your own controls (a zoom button, a badge, the gallery's dots), the bottom left first. It works on Shopify stores, in every language the assistant speaks, and never shows where "See it on you" is switched off. You can also switch it with the API: PATCH /v1/widget/settings with tryOnButton: true.

Two options tune it, both optional:

html
<script>
  window.StylorConfig = Object.assign({
    tryOn: {
      corner: 'top-right',              // 'bottom-left' (default), 'bottom-right', 'top-left' or 'top-right'
      image: '.product__media img',     // a CSS selector for the photo, if yours isn't found
    },
  }, window.StylorConfig || {});
</script>

Add debug: true beside them to have the script say in the console which photo it chose.

Analytics

The assistant records its own usage (conversations, products shown, add-to-carts) in your Analytics. On your storefront it keeps a session id in sessionStorage, and a visitor id in localStorage for 13 months only when the shopper has allowed analytics. Under the same consent it also keeps the current visit's id and its last activity time in localStorage, so a page opened in another tab within 30 minutes is the same visit and not a new one. On your public pages it records how long each page was open, how far it was scrolled, and which links, buttons or pictures were tapped (the kind of element and its visible label; never what a shopper types, and nothing on account or checkout pages). A visit's replay in Analytics shows these on a copy of your public page as it was around the visit. Stylor fetches those copies itself, as an anonymous visitor would and without your scripts: a page your shoppers visit is checked about once a week, a few pages a minute at most, and a new copy is kept when the page has changed. It also records how the storefront's cart changes, when a shopper leaves for checkout, and, when they come back to your store afterwards, that an order was placed; for that it remembers the cart it last saw (in localStorage when the shopper has allowed analytics, otherwise sessionStorage). All of these are keyed sgpt_*.

In your dashboard, Analytics shows this on one page: your audience (how many visits, what we know about each, where they came from, and the shoppers who came back); carts and orders (what carts held, who went to checkout, the orders your store's pages could see, and how much of each the assistant added or showed first); the result of a widget test, if you ran one; and every visit, each with a replay. A replay is redrawn from what the assistant recorded, in your widget's theme. It is not a recording of your page, and a shopper is shown as a code, never a name. We do not keep shoppers' IP addresses; a visit's country comes from the network it arrived over, or else from the browser's time zone.