---
title: How to set up web analytics tracking
slug: test-archbee/how-to-set-up-web-analytics-tracking
description: Learn how to add Google Analytics tracking code to your documentation portal using Custom Code in JavaScript with this helpful document. Discover how users with Scaling or Enterprise plans can integrate web analytics tools by adding a Custom Code JavaScri
docTags: 
createdAt: 2022-07-15T14:01:06.000Z
---

This feature allows for integration with many web analytics tools since they work by loading a JS snippet.

If you decide to use Google Analytics, here is what you need to do.

:::hint{type="danger"}
&#x20;Google Analytics 4 is the next-generation measurement solution, replacing Universal Analytics. On July 1, 2023, standard Universal Analytics properties stopped processing new hits. If you still rely on Universal Analytics, we recommend you use Google Analytics 4 going forward.
:::

:::::WorkflowBlock
:::WorkflowBlockItem
To add the Google Analytics tracking code to your documentation portal, you’ll need a piece of code known as the “**Global Site Tag**.”

You can find this in your Google Analytics admin dashboard. Locate the tracking code under **Admin -> Data Streams -> Web stream details**.
:::

:::WorkflowBlockItem
Copy the global site tag below into the **Custom JavaScript** field under **Space Settings -> Custom Code**.

![](https://api.archbee.com/api/optimize/bNBm7nPJgXjbjLyfbHNh2/rwPtIGtKjQqfSmJ5MWIPU_guides-customjs-light.png "Globat site tag code")
:::

:::WorkflowBlockItem
Make sure you replace the `insert measurement ID` with your own ID.

```javascript
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-80B7MQZ06B"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', '{insert measurment ID}');
</script>
```
:::

::::WorkflowBlockItem
After the code is added, click **Save** and publish to production.

:::hint{type="warning"}
For security reasons, custom code is only included on a custom domain.
:::
::::
:::::

::loom{url="https://www.loom.com/embed/4418fc0ea3324216a3bb653d96159b1a?sid=387f43f4-76e7-46ed-85d1-13b75c3461f2"}
