# Add Google Analytics or Google Tag Manager

_Category: Integrations and API_

Send your help center's traffic to Google Analytics 4 or Google Tag Manager, next to HelpCenter.io's built-in statistics. You add Google's code once in the template editor, and it runs on every page of your help center.

**Who can do this:** Owners and Admins (Editors through **Customize** on your help center) · **Plans:** All plans

## Add Google Analytics 4

You need your measurement ID from Google Analytics. It looks like `G-XXXXXXXXXX`.

1. In the left menu, click **Template editor**, then open **Advanced**.
2. Under **Script injections**, click **External script**.
3. In **Source URL**, paste `https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX` with your own measurement ID at the end.
4. In the position menu, choose **End of <head>**, and give the script a label, such as "Google Analytics".

![Screen recording. In Advanced, under script injections, click External script. Paste the script address into Source URL. Choose where it loads, and give it a label.](https://helpcenter-io.s3.amazonaws.com/uploads/self/i1KpD1SfYTWkHC1rwnVgjSwqbCIPwP79p7h2bmwn.gif)
Each script has a label, a position and its own settings.

1. Click **Inline script**, choose **End of <head>** as its position, and replace the text in **Inline body** with this code, using your measurement ID:

```
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
```

1. Click **Publish**, then **Publish** again to confirm.

Paste only the JavaScript in **Inline body**: HelpCenter.io wraps an inline script in `<script>` tags for you.

Prefer to paste Google's snippet exactly as Google gives it? Click **HTML snippet** instead of the two scripts, paste the whole snippet, and choose **End of <head>**. HTML snippets appear on the page exactly as you enter them.

## Add Google Tag Manager

Tag Manager gives you two pieces of code. Add each as its own HTML snippet:

1. In the template editor, open **Advanced** and under **Script injections**, click **HTML snippet**.
2. Paste the first piece, the one that starts with `<script>`, and choose **Start of <head>**.
3. Click **HTML snippet** again, paste the second piece, the one that starts with `<noscript>`, and choose **Start of <body>**.
4. Publish your design.

## Verify your help center in Google Search Console

Choose the HTML tag method in Search Console and copy the `<meta name="google-site-verification" …>` tag. In the template editor, click **HTML snippet**, paste the tag and keep the position **End of <head>**. Publish your design, then go back to Search Console and verify.

## Good to know

- **Nothing runs until you publish.** Scripts are part of your design, so they go live with your next publish. See [Publish your design](https://self.helpcenter.io/content/publish-your-design).
- **Limit a script to some pages** with **Run only on specific pages…**: pick **Home**, **Category**, **Article**, **Search**, **Contact** or **Not found**. Leave it empty to run on every page.
- **Switch a script off** without deleting it by unticking **enabled**, then publish.
- **Consent is up to you.** Google Analytics and Tag Manager can set cookies. If your visitors must agree to analytics first, add your consent banner or consent tool along with the tags.
- **Built-in statistics need no setup.** HelpCenter.io already counts visitors, searches, article views and ratings. See [Read your help center statistics](https://self.helpcenter.io/content/statistics).

## Troubleshooting

**Google Analytics shows no data.** Check that you published your design, that **enabled** is ticked on both scripts, and that the measurement ID is the same in the **Source URL** and the inline code. Then open your help center and look at the Realtime report in Google Analytics.

**The inline script doesn't run.** **Inline body** takes JavaScript only. If you pasted Google's `<script>` tags into it, remove them, or use an HTML snippet for code that includes its own tags.

## Related articles

- [Add analytics and other scripts](https://self.helpcenter.io/content/scripts)
- [Read your help center statistics](https://self.helpcenter.io/content/statistics)
- [SEO settings for your help center](https://self.helpcenter.io/content/seo-settings)
