Install Google Analytics code without plugin
-
I always used a WordPress plugin to add my GA to my WordPress websites. Now I want to add the code without the need of a plugin. I want to add two things to the default code:
– Increase the siteSpeedSampleRate to 50%
– Anonymize IP adressesSo this is the code I have right now, and I like to know if I set this up correctly:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-XXXXXXXX-X', {'siteSpeedSampleRate': 50}); gtag('config', '<GA_MEASUREMENT_ID>', { 'anonymize_ip': true }); </script>
I don’t use the tagmanager, so maybe I can delete the line?
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
Thanks for your help ??
Alwin
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Install Google Analytics code without plugin’ is closed to new replies.