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.
Add GoodMetrics as a Custom HTML tag
Section titled “Add GoodMetrics as a Custom HTML tag”- Open your GTM account.
- Create a new Custom HTML tag.
- Paste the following code and replace the
script.dataset.gmID with your uniquedata-gmID:
<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>- Set the trigger to All Pages.
- Save and publish your tag.
Verify your installation
Section titled “Verify your installation”- Visit your website.
- In GoodMetrics, open the Realtime report.
- 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-gmID with your own. - Still stuck? Contact us and we’ll be happy to help.