Add the GoodMetrics tracking script to your Shopify store — works with every theme, including Online Store 2.0 themes like Dawn.
You can add GoodMetrics to your Shopify store by placing your tracking script in your theme’s layout file. This works with every Shopify theme — both vintage and Online Store 2.0 themes like Dawn — because every theme has a theme.liquid file that controls the <head> on all storefront pages.
First, you’ll need your unique tracking script. If you don’t have it yet, here’s how to retrieve it. It looks like this:
<script id="gmScript" data-gm="XXXXXXXX" src="https://cdn.goodmetrics.io/goodmetrics.min.js"></script>💡 Your
data-gmID is unique to your store, so copy your own script from your site settings rather than the example above.
Add the script to your theme
Section titled “Add the script to your theme”💡 Adding the script is a single, low-risk line, so editing your live theme directly is fine. If you’d prefer a safety net, duplicate your theme first (Themes → ⋯ → Duplicate) — you can republish the copy to revert if you ever need to.
- From your Shopify admin, go to Online Store → Themes.
- Find the theme you want to edit (usually your live theme) and choose ⋯ → Edit code.
- In the Layout folder, open
theme.liquid. - Find the closing
</head>tag (press Ctrl/Cmd + F to search for it) and paste your GoodMetrics script on the line immediately before it. - Choose Save.
Your script now loads on every storefront page.
Verify your installation
Section titled “Verify your installation”- Visit your storefront.
- In GoodMetrics, open the Realtime report.
- Confirm that your visit appears in the report.
If you don’t see your visit:
- Confirm you pasted the script into the published theme (not an unpublished copy) and saved your change.
- Make sure the script is inside
theme.liquid, just before</head>. - Still stuck? Contact us and we’ll be happy to help.
What this tracks
Section titled “What this tracks”This installs GoodMetrics across your entire storefront — your home page, collections, product pages, and cart — so you’ll see your traffic, sources, and on-site behavior in full.
As with any analytics tool added through your theme, the script doesn’t run on Shopify’s checkout, which Shopify serves from a separate system outside your theme.