Set Up A/B Testing on Your Store
Before your A/B tests can show to shoppers, Dialogue needs to be switched on in your store. On Shopify this is a single switch in your theme. No code changes, and it won’t slow down your store.
If you use the Dialogue app on Shopify
Section titled “If you use the Dialogue app on Shopify”- In your Dialogue dashboard, open A/B testing from the left menu.
- In the Setup Status box, click Show install steps. You’ll see the steps below, plus the script for other platforms.
- Open your Shopify Admin.
- Go to Online Store → Themes and click Customize on your active theme.
- Click App embeds in the left sidebar.
- Switch on Dialogue AB Commerce.
- Click Save in the top right.
That’s it. You can now create your first test.
If you use the Dialogue A/B testing app
Section titled “If you use the Dialogue A/B testing app”If you installed the standalone Dialogue A/B testing app from the Shopify App Store, your dashboard is at ab.nowdialogue.com.
- Open Online Store → Themes in your Shopify Admin and click Customize on your active theme.
- Click App embeds in the left sidebar.
- Find Dialogue by PDQ and switch it on.
- Click Save.
Back in the A/B testing dashboard, the setup status shows when Dialogue is active on your store.
Headless Shopify store
Section titled “Headless Shopify store”If your Shopify store runs on a custom storefront (Hydrogen, Next.js or another framework), the theme app embed can’t reach it. Your developer adds the Dialogue script to the site’s code once instead.
-
Open A/B testing in your Dialogue dashboard, click Show install steps and choose Headless store.
-
Copy the snippet. It looks like this, with your own store’s file name:
<link rel="preload" href="https://cdn.nowdialogue.com/prod/stores/extension_script/<your-file>.js" as="script"><script defer src="https://cdn.nowdialogue.com/prod/stores/extension_script/<your-file>.js"></script> -
Add it to the
<head>of the layout that every page uses. -
If your site has a Content Security Policy, allow
https://*.nowdialogue.comfor scripts, styles, images and connections. -
Keep the Dialogue app installed in Shopify. Purchases are counted from Shopify’s checkout.
Hydrogen
Section titled “Hydrogen”Hydrogen adds a Content Security Policy by default. In app/entry.server.jsx, add our domain:
const {nonce, header, NonceProvider} = createContentSecurityPolicy({ shop: {checkoutDomain: context.env.PUBLIC_CHECKOUT_DOMAIN, storeDomain: context.env.PUBLIC_STORE_DOMAIN}, scriptSrc: ['https://*.nowdialogue.com'], connectSrc: ['https://*.nowdialogue.com'], styleSrc: ['https://*.nowdialogue.com'], imgSrc: ['https://*.nowdialogue.com'],});Then in app/root.jsx, add the script inside <head> with the page nonce:
const nonce = useNonce();// inside <head><script nonce={nonce} defer src="https://cdn.nowdialogue.com/prod/stores/extension_script/<your-file>.js" />Next.js
Section titled “Next.js”In the root layout (app/layout.tsx, or pages/_document.tsx on the older Pages Router), add the script inside <head>:
<head> <script defer src="https://cdn.nowdialogue.com/prod/stores/extension_script/<your-file>.js" /></head>Check that it works
Section titled “Check that it works”Open your store and, in the browser console, type window.DAI_EXP_MANAGER. If it returns something other than undefined, the script is running.
Good to know on headless stores
Section titled “Good to know on headless stores”- Page changes without a reload. Tests are checked on each full page load. If your site switches pages without reloading, a test set for one page starts when the shopper lands on or reloads that page.
- Page types. Tests aimed at a page type (product, collection, cart) read it from the address, such as
/products/...and/collections/.... If your addresses look different, set the page type before the script loads, for examplewindow.DAI_shopify_template = 'product'. - Theme template tests switch between Shopify theme templates, so they don’t apply to a custom storefront.
- Purchases. Shopify’s checkout runs on a different web address from a custom storefront, so some purchases may not be linked to the version a shopper saw. Views and clicks are counted as usual.
If your store is not on Shopify
Section titled “If your store is not on Shopify”- Open A/B testing in your Dialogue dashboard.
- Click Show install steps and choose Manual Code.
- Copy the script and paste it into the
<head>section of your site.
What about the Chrome extension?
Section titled “What about the Chrome extension?”You no longer need the Chrome extension. Tests are built in the visual editor inside your dashboard. The extension is only a backup for the rare case where the editor can’t load a preview of your store. If that happens, the editor shows a Download Extension button.
Next steps
Section titled “Next steps”- Test website elements with the visual editor
- How Dialogue picks an A/B test winner
- A/B tests, page speed and flicker
Need help? Open the chat in your Dialogue dashboard and ask Dia, or ask to talk to a person.