Skip to main content

Tracking script installation

To start collecting data with GoodMetrics, you’ll need to install a small tracking script on your website. This script enables GoodMetrics to track pageviews and custom events in real time.

When you create a new account, your unique tracking script is shown during onboarding. If you’ve already completed onboarding or added another website, here's how to retrieve your script.

Installing your tracking script

To install the GoodMetrics tracking script, copy your unique tracking code and add it to your website. We recommend placing it in the <head> section.

Your tracking script will look something like this:

<script id="gmScript" data-gm="XXXXXXXX" src="https://cdn.goodmetrics.io/goodmetrics.min.js"></script>

💡 This is just an example. Your data-gm ID will be unique, so make sure to copy your script tag directly from your site settings.

Once installed, your script will begin sending pageview and event data to GoodMetrics in real time.

Verifying your script installation

After installing the script, follow these steps to confirm it’s working:

  1. Visit your website (where you installed the tracking script).
  2. In GoodMetrics, open the Realtime report.
  3. Confirm that your visit appears in the report.

If you don’t see your visit:

  • Review the steps above and verify that you copied your script correctly.
  • Double-check that the script is present in the <head> section of your website.
  • Still stuck? Contact us and we'll be happy to help.

Installing with Google Tag Manager (optional)

If you're using Google Tag Manager (GTM), you'll need to follow these steps instead:

  1. Open your GTM account.
  2. Create a new Custom HTML tag.
  3. Paste the following code and replace the script.dataset.gm ID with your unique data-gm ID:
<script>
var script = document.createElement('script');
script.id = 'gmScript';
script.dataset.gm = 'XXXXXXXX'; // Replace with your unique website ID
script.src = "https://cdn.goodmetrics.io/goodmetrics.min.js";
script.defer = true;
document.getElementsByTagName('head')[0].appendChild(script);
</script>
  1. Set the trigger to All Pages.
  2. Save and publish your tag.

Once published, verify your setup using the steps above.