Skip to content
fusionaly_ GitHub

Shopify Analytics Without Cookies

Add Fusionaly to a Shopify store by editing theme.liquid. It counts store pages, product clicks, and add to cart, with no cookies.

In Shopify, you add the Fusionaly script to the layout of your theme, theme.liquid. Fusionaly then counts every page of your store that uses the theme.

Before you start

You need a Fusionaly server, with your site's domain added as a website. Fusionaly takes events only from the domains you added. See Installation.

In the examples, replace analytics.example.com with the domain of your Fusionaly server.

Add the script

  1. In the Shopify admin, open Online Store > Themes.

  2. Next to your live theme, click …, then Edit code.

  3. Open layout/theme.liquid, and add the script just before </head>:

    layout/theme.liquid
    <script defer src="https://analytics.example.com/y/api/v1/sdk.js"></script>
    </head>

Add the domain that your customers visit as a website in Fusionaly. If they also open the myshopify.com address, add that domain too.

Page changes

Shopify themes load each page in full, so Fusionaly counts each page without any setup.

Track events

Fusionaly counts page views and button clicks without any setup. To give an event your own name, use the data-fusionaly-event-name attribute. See Tracking.

Add the attribute to a button in your theme. Liquid can fill the metadata. For example, in the product form section:

<button type="submit" name="add"
data-fusionaly-event-name="add_to_cart"
data-fusionaly-metadata-product="{{ product.handle }}">
Add to cart
</button>

Check that it works

  1. Open your site in a normal browser window. Fusionaly skips automated browsers, such as Playwright, and browsers that send Do Not Track.
  2. In the developer tools, open the network tab, and find a POST request to /x/api/v1/events. A 403 status means that your site's domain is not added as a website.
  3. Open your Fusionaly dashboard. The visit shows up within about a minute.

Notes

  • Shopify runs the checkout, the thank-you page, and the order status page outside your theme. Fusionaly does not see these pages, so it does not count purchases on its own.
  • The edit belongs to this theme. If you publish another theme, add the script to it, too.

Next steps

Guides for other frameworks: Next.js, React, Astro, Nuxt, SvelteKit, WordPress, Webflow, Ghost, Hugo, and the generic guide.