- AuthorPosts
- January 6, 2021 at 2:29 pm #32721KristinGuest
Hello,
I want to set up google analytics for my website. To do that, Analytics is telling me to add a Global Site Tag (gtag.js) and copy/paste the code provided as the first item into the <head> of every webpage I want to measure.
Can you tell me how to do this? I currently have the Swifty theme on WordPress.
Thank you so much,
Kristin Clark
January 6, 2021 at 2:44 pm #32762Jesse OwensKeymasterHi Kristin-
There are a few ways you can add Google Analytics to your site, ranging from very easy to quite technical.
My personal favorite way is with the official Site Kit by Google plugin. With Site Kit, you won’t need to worry about manually copying-and-pasting your code in, and it ties together Analytics, Search Console, and other Google products along with some in-dashboard insights about your traffic.
There are also a lot of other plugins available to add Analytics to your site without getting into your site’s code.
If you’d like to stick with pasting your code in, the best way is to use a plugin like Code Snippets so that you don’t have to modify your theme’s code. Once you have Code Snippets installed, you can use a snippet similar to this:
add_action( 'wp_head', function () { ?> <script> /* paste your Analytics code here */ </script> <?php } );
- This reply was modified 4 years ago by Jesse Owens. Reason: fixing code snippet
- AuthorPosts
- The topic ‘How to add google analytics tags to website’ is closed to new replies.