How to add Google Analytics to WordPress

Welcome, dear agency owners, every website is just a tool, and value is created by doing something like generating leads through SEO, Social Media or PPC campaigns – anyway, you’ll need to install any analytics, so today we’ll talk about the most popular Analytics for Web – Google Analytics.

Why Add Google Analytics?

The basic answer is to know where your visitors and leads are coming from. Without analytics, you won’t be able to measure the scale and success of an aqcuisition channel, and your marketing will be stuck in the darkness. However, having analytics opens your eyes on situation with a website in real time and in past periods:

  • How many users visited website
  • Where are they from
  • How much time they spend on each page
  • Is your content interesting enough?
  • CAC by channel cost
  • LTV by channel cost
  • etc.

How to create a Google Analytics Account?

Just navigate to the main Google Analytics webpage and hit “Go to Analytics”. You’ll be asked to log in and that’s where creation starts.

  1. Account creation – could contain couple of Analytics properties.

    2. Property creation – will track something like website data or app data

      3. Select business size and category

        4. Select why you’re going to use Google Analytics

          How to Get Your Tracking ID?

          After saying “yes” to all legal data, entering your website URL and label to the created analytics, and specifying web/ios/Android platform for using analytics – You’ll see the code that should go to the website. The main thing here is the ID – on the screenshot it’s “G-QS2HN4QQC1” – now we need to add this code to the website

          How to Add Google Analytics to WordPress?

          Basically, there are 2 ways, and really, if you don’t know what to do, I’d recommend the plugin. It’s official recommendation from Google for WordPress and should work in 9 out of 10 situations and then we’ll move to that 1 of 10 situations

          How to install GA using a plugin?

          Search through the plugin directory or download the Site Kit directly from the Google plugin from the main plugin directory and authenticate with your Google account. In a few clicks you will be able to add one or multiple tracking tools:

          • Google Analytics
          • Google Tag Manager
          • Google Search Console
          • AdSense
          • PageSpeed insights
          • Tag Manager
          • Sign in with Google
          • Reader Revenue Manager
          • Ads

          For somebody who’s not a developer himself, a pretty useful plugin. Each tool have separate toggler to activate. Best solutions for non-devs. Even this website uses this plugin because I like it, really.

          Adding Code Manually

          Welcome to the advanced territory. Now you’ll be operating with code. Nothing crucial though, but a lot of questions could be answered with “it depends”. So, first we’ll try to add the code under header.php file

          Go to WP admin -> Appearence -> File Editor ( For classic themes ) and find header.php file

          How to Verify the Installation of Analytics?

          The task is not finished if it’s not tested properly, so now you need to flush all caches, visit your Google Analytics real-time reports, and open a certain page on the website. Under real-time reports, you should see your own activity or your + other visitors’ activity.

          Google says you should wait 24 hours to aggregate the data – but it’s not the same for real-time reports. If after 1 hour analytics still not showing any data on real-time reports – means it

          Common Setup Mistakes

          Easy to add, but also easy to mess up. Most common analytics issues seems like:

          • No data is tracked,
          • Not full data is tracked
          • Double/triple data is tracked

          First of all, a basic check is to open the page source code and verify that the code is output on the page and that the ID is correct. If it’s there – data should be tracked.

          Second, if some data is not tracked – you may have some JS issues or Optimisation issues and it’s time to reach out to developer to investigate this, remove all the analytics and set up it again.

          Double/tripple data is tracked means you may have Google Analytics installed in few places – usually it’s GTM and Plugin or GTM and Code, but definitely two tracking codes on the page

          Final Tips

            Follow the guide, flush the cache, and don’t hesitate to reach out to me on LinkedIn if none of the methods above worked – and I’ll do my best to help you out and update the guide after that.

            In my opinion, 9 of 10 situations – agency owners, PMs or Marketing or SEO managers should be able to do this job themselves. I’ll do a screencast shortly to help out with the step by step guide plus screen recording for maximum confidence.

            Best of luck with client’s projects

            Vitalii Omelchenko
            Founder at Codelibry and WordPress enthusiast. Helping digital agencies to protect their margins and do better at website delivery.Need help with wordpress builds? Book a call using the Contact page
            our Blog

            Explore our Latest Insights

            company icon
            How to add Google Analytics to WordPress
            WordPress
            May 4, 2026
            company icon
            How to improve SEO WordPress in 2026
            WordPress
            May 1, 2026
            company icon
            How to improve WordPress security
            WordPress
            April 21, 2026
            whatsapp icon