Problem with Code Snippet for Google Analytics
-
I’m setting up my GA4 and having a problem.
On my GA4 home page it says:
“No data has been received from your website yet.
Start collecting data by ensuring that your website is tagged with the measurement ID: G-xxxxxxxxx”In tag manager it shows:
Edit container
Container ID
GTM-xxxxxxxx1 (Allowed tags: All)
GTM-xxxxxxxx2 (Allowed tags: Google only)I’ve installed the second container (Google only).
The problem is it says “Data collection is not active for your website”.
On home page it says I should install the first container.Questions:
- Why are there two different containers and which should I install?
- Where do I find the code for the first container?
The code I used in Code snippets is:
add_action( 'wp_head', function () { ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtm.js?id=GTM-xxxxxxxx2"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());
gtag('config', 'GTM-xxxxxxxx2');
</script>
<?php });
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.