Tagged: 3rd-Party Plugin, Troubleshooting
- AuthorPosts
- October 13, 2020 at 12:03 pm #28170BryanGuest
Hi.
I have searched high and low.
I need to add this code into the header of all my pages.<!-- Global site tag (gtag.js) - Google Ads: [redacted] --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-[redacted]"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-[redacted]'); </script>
October 13, 2020 at 12:16 pm #28210Jesse OwensKeymasterHi Bryan-
My personal recommendation for adding Analytics or any other Google gtag script is the official Google Site Kit plugin.
This will allow you to use Google-native tools to manage your tags as well as have access to Analytics and Search Console data directly in your Dashboard.
That said, there are many other plugins to add gtags to your site, or you can choose to manually insert it using a plugin like Code Snippets. If you choose to go the manual route, add a function like this (Code Snippets includes an Example JavaScript Snippet you can modify):
add_action( 'wp_head', function () { ?> <!-- Global site tag (gtag.js) - Google Ads: [redacted] --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-[redacted]"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-[redacted]'); </script> <?php } );
Keep in mind that I’ve redacted your personal gtag identifier code, so don’t copy and paste this code directly- use the code you were provided by Google.
- AuthorPosts
- The topic ‘Need to know how to add this to some page headers’ is closed to new replies.