Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #32721
    Kristin
    Guest

    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

    #32762
    Jesse Owens
    Keymaster

    Hi 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 3 years, 10 months ago by Jesse Owens. Reason: fixing code snippet
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘How to add google analytics tags to website’ is closed to new replies.