Code Snippet for Google Analytics
-
Hi!
I′m trying to add Google Analytics to the header of my site using Code Snippets, but can′t seem to get it right.
It′s just not counting all the visits. Can you help?
I′m using the example you gave to someone earlier.
I changed the GA Tracking ID in the example here, but I′m using the right one on teh site.
add_action( ‘wp_head’, function () { ?>
<script>
// <!– Global Site Tag (gtag.js) – Google Analytics –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=My_GA_TRACKING_ID”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag(‘js’, new Date());gtag(‘config’, ‘My_GA_TRACKING_ID’);
</script></script>
<?php } );
The page I need help with: [log in to see the link]
- The topic ‘Code Snippet for Google Analytics’ is closed to new replies.