Skip to content

Install GoodMetrics with Google Tag Manager

Deploy the GoodMetrics tracking script on your website using Google Tag Manager (GTM).

If you manage your site’s tags with Google Tag Manager (GTM), you can deploy the GoodMetrics tracking script through a Custom HTML tag instead of editing your site’s code directly.

You’ll need your unique data-gm ID. If you don’t have your script yet, here’s how to retrieve it.

  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.
  1. Visit your website.
  2. In GoodMetrics, open the Realtime report.
  3. Confirm that your visit appears in the report.

If you don’t see your visit:

  • Double-check that the tag is published and the trigger is set to All Pages.
  • Confirm you replaced the data-gm ID with your own.
  • Still stuck? Contact us and we’ll be happy to help.