Using Google Universal and Google Analytics 4 at the same time
Integrations
Google Analytics
If you want to use Google Analytics Universal and Google Analytics 4 on your site at the same time, both accounts must be available for our integrations.
If you integrate Google Analytics on a page, this is usually done via the Google Tag Manager, which places the Analytics script directly on your page with the desired account. However, according to Google, this Analytics script should only be played out once globally on the page. If you now use the Google Tag Manager to place the script on the page for both Universal and GA4, the Tag Manager hides some content. This missing content can lead to problems when recording the Google Client ID.
The solution to this problem is to simply extend the Google script to include the additional account. Here is an example:
Before, only with Universal Account
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-159839765-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-159839765-1');
</script> <!-- End Google tag (gtag.js) -->
Afterwards, combination script with universal and GA4 account:
<!-- Google Kombi tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-159839765-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-159839765-1');
gtag('config', 'G-PRECVR6BWJ');
</script> <!-- End Google Kombi tag (gtag.js) -->
This is also the procedure recommended by Google:
The new tag with both accounts can then be installed on the page manually or again via the Google Tag Manager.