Skip to content
Docs menuInstall CentPath › Install the script

Add CentPath to Shopify

On this page

Add CentPath to your Shopify theme, so every page of your storefront counts its visits.

Before you start

CentPath counts the pages your theme draws: your home page, collections, products, the cart and your blog. Shopify's checkout pages, the thank-you page among them, don't use your theme, so the snippet in theme.liquid doesn't run there, and CentPath doesn't see checkouts or sales made through Shopify's checkout.

If you also sell through your own Stripe checkout outside Shopify, count your Stripe sales.

1. Copy your snippet

In CentPath, open your site, go to Setup → Install and click Copy. The snippet you copy holds your site's own id, so every visit counts for the right site:

<script>window.analytics = window.analytics || Object.assign([], { q: [], goal: function () { this.q.push(arguments); } });</script>
<script defer src="https://centpath.app/script/p.js" data-site-id="YOUR_SITE_ID"></script>

2. Open your theme's code

  1. In your Shopify admin, go to Online Store → Themes.
  2. Next to your current theme, click the menu button (the three dots) and pick Edit code. To keep a copy you can go back to, duplicate the theme from that menu first.

3. Paste the snippet into theme.liquid

  1. In the list of files, open theme.liquid in the layout folder. It's the layout every page of your storefront is drawn in, so the snippet goes here once.
  2. Find </head> and paste the snippet on the line above it.
  3. Click Save.

Verify the setup

  1. Open your store in a private window and load a page.
  2. In CentPath, look under the steps in Setup → Install: Waiting for your first pageview… turns into First pageview received. once the visit arrives.
  3. If it said First pageview received. before you started, your site has had visits already: look for this one in your dashboard instead. Reload it, and the visit shows in the Visits feed, usually within a minute.

Check your installation shows more ways to check a page.

Troubleshooting

Visits stopped after you changed theme

Each theme has its own theme.liquid, and a new theme, or a new version of yours, doesn't carry your edit. Paste the snippet into the new theme's theme.liquid as in step 3.

Checkout pages show no visits

Shopify's checkout doesn't use your theme, so the snippet doesn't run there and CentPath counts no visit. Your storefront's pages, the cart included, are counted.