# Google Analytics 4 Tracking tag

**URL:** <https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920>\
**Category:** Data collection and tags\
**Created:** [March 28, 2023, 2:50pm UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920 "2023-03-28T14:50:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flasheart](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/flasheart/32/2706_2.png) [@flasheart](https://community.piwik.pro/u/flasheart)\
**Post date:** [March 28, 2023, 2:50pm UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920/1 "2023-03-28T14:50:38Z")

</div>

This [page](https://help.piwik.pro/support/tag-manager/google-analytics-tracking/?pk_vid=16800145054f77af) states that Piwik is working on a GA4 version of the Google Analytics Tracking tag.

Is there currently another way to add the GA4 tag to a site via Piwik Tagmanager?

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 28, 2023, 7:38pm UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920/2 "2023-03-28T19:38:54Z")

</div>

Hi. Sure, you can add the GA4 snippet ([Google tag](https://support.google.com/analytics/answer/9744165?hl=en#install-manually&zippy=%2Cin-this-article%2Cinstall-a-google-tag)) via custom code tag. It should be available under Admin → Data streams → Web → Your site → View tag instructions. 🙂

---

<div class="post-metadata">

**Author:** ![flasheart](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/flasheart/32/2706_2.png) [@flasheart](https://community.piwik.pro/u/flasheart)\
**Post date:** [March 28, 2023, 10:28pm UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920/3 "2023-03-28T22:28:55Z")

</div>

That’s easier than expected 🙂 Going to try it out, thanks!

---

<div class="post-metadata">

**Author:** ![Thomas\_Anode\_FR](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/thomas_anode_fr/32/1425_2.png) [@Thomas\_Anode\_FR](https://community.piwik.pro/u/Thomas_Anode_FR)\
**Post date:** [April 6, 2023, 9:29am UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920/4 "2023-04-06T09:29:15Z")

</div>

Hello @Admin, this snippet corresponds to the gtag.js:

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

  gtag('config', 'G-X');
</script>

```

Google says it has to be implemented right after the `<head>` element. Therefore, I might be wrong but, using a Piwik PRO custom code tag to push it might cause GA4 to not work correctly. Because the gtag.js will be pushed in the `<body>` section rather than the `<head>`.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [April 6, 2023, 9:36am UTC](https://community.piwik.pro/t/google-analytics-4-tracking-tag/1920/5 "2023-04-06T09:36:06Z")

</div>

Technically there should be practically no difference. They simply want to load it as soon as possible and I get it. Our tag manager also works when installed within `<head>`, but it’s not recommended by us as we fully test just the installation in `<body>`.
