How to Add Google Analytics to WordPress — 2024 Setup Guide

Using Google Analytics with WordPress provides some incredible insights. You can learn how people engage with your website, where traffic comes from, how visitors interact with content, and what elements and pages are popular with your audience. You can then use this to improve your site design, determine what types of content or products to create, and better target your advertising.  

The good news is that the information Google Analytics provides about your WordPress website is free. But adding it to WordPress can require some time and patience. 

As you’ll learn throughout this guide, manually adding Google Analytics to WordPress is certainly possible, but is often complicated for beginners. It also provides complex analytics and stats that might be way more than you need, especially if you own a small website and just want to discover more information about visitors and traffic sources. 

The focus of this guide is on how to add Google Analytics to WordPress, but we’ll also tell you a bit more about a tool called Jetpack Stats. This alternative generates simple data, charts, and graphs, can be easier to install, and also integrates with Google Analytics if you need. Automattic, the company behind WordPress.com, is responsible for Jetpack Stats, so it’s a great choice for many WordPress site owners.   

Why connect Google Analytics to WordPress?

Using Google Analytics on WordPress is a good idea if you want to learn more about your website and how people interact with it.

Say you use WordPress for your small business site. Integrating Google Analytics with the platform helps you discover how long people stay on your site, where those visitors come from, what actions they take, what content they engage with, and other insightful statistics. 

WordPress doesn’t have any in-built statistics, so adding Google Analytics to the platform provides a whole new perspective on your website. You can uncover information that will make your site more successful and relevant to your audience.

The easiest way to add Google Analytics to WordPress is by using Jetpack. 

Can I see my WordPress analytics without Google?

WordPress doesn’t have a built-in way to view site analytics from your dashboard. Google Analytics is one of the most popular tools for collecting and viewing site stats, but it’s not necessarily the best choice for every site owner. 

While Google Analytics is free to use and provides valuable information, it can be complicated for beginners and hobbyists because it generates a massive amount of data. The platform displays statistics and analytics via complex reports, dashboards, charts, and graphs that can be difficult to interpret. 

Say you have a personal website and just want to analyze visitors, traffic sources, and other simple information. Google Analytics certainly delivers this data, but it can require scrolling through countless charts and graphs to find what you need. If this sounds more like a chore than a benefit, Google Analytics might not be right for you. 

Luckily, you can view analytical information about your WordPress site without Google. Jetpack Stats is the simplest and quickest way to access site analytics right in your WordPress dashboard. Use it to get a solid, reliable overview of site performance without a steep learning curve.

But you can also easily and quickly connect Google Analytics to your site with Jetpack. As you’ll see in a moment, this is a much simpler approach than manually adding tracking codes, especially for beginners. Combining these two gives you the absolute best of both worlds!

Requirements to add Google Analytics to WordPress 

Are you ready to add Google Analytics to WordPress? Here are a few things you need before you start:

Signing up for a Google Analytics account is a simple process. You can create a dedicated account just for your site, or if you already have a Google profile for tools like Gmail, you can sign in and visit analytics.google.com to associate it with that existing account. Read on for more details.

How to sign up for a Google Analytics account and get your measurement ID

Registering for Google Analytics is free, and required whether you connect Google Analytics to WordPress with Jetpack or manually. All you need is a Google account. Follow this step-by-step guide to sign up for a Google Analytics account:

  1. Head to Google Analytics on your desktop computer or mobile device.
  2. Log in to an existing Google account or register for a new one.
  3. Create a name for your Google Analytics account. 
  4. Customize your data sharing settings. This gives you control over how much information you want to share with Google.
  5. Click Next.
create an account name in Google Analytics

Now, you’ll need to choose a Google Analytics property — the WordPress website that Google will track. Google put an end to Universal Analytics in July 2023, so you should create a property in Google Analytics 4 (GA4).

  1. Enter a property name, the name of your business or website.
  2. Choose your reporting time zone and local currency.
  3. Click Next.
adding property details for Google Analytics

The next screen is all about your business or site:

  1. Select an industry category that best matches your business (or site).
  2. Choose a business size from the available categories. 
  3. Specify how you intend to use Google Analytics. For example, you might want to use the tool to measure customer engagement or increase conversions. You can select as many categories as you like.
  4. Click Create.
  5. Review, and if you agree to the terms, click I Accept in the Google Analytics Terms of Service Agreement popup. 
  6. Choose how you want to receive email notifications from Google in the My Email Communications popup.
adding business details to Google Analytics

The following screen is about setting up data streams, which helps Google collect information from your WordPress site for analytics. Click Web under the Choose a Platform section.

On the next screen, you need to enter your WordPress site URL and stream name — the name of your website. You’ll notice that Google Analytics has Enhanced Measurement on by default. This option automatically measures content and interactions on your site. Toggle this feature off if you just want Google to track page views.

Click Create Stream.

Finally, Google Analytics will provide you with a measurement ID (known as a “tracking ID” in Universal Analytics) so you can connect this tool to WordPress.

setting up web stream details and finding a measurement ID

Tip: Copy this measurement ID in your internet browser or leave the tab open. You’ll need this information later.

Now that you have an account and measurement ID, it’s time to add Google Analytics to your WordPress site!

There are two main ways to do this:

  1. Using a plugin like Jetpack.
  2. Adding Google Analytics to WordPress manually.

How to set up Google Analytics on WordPress with a plugin

Here’s a step-by-step guide to using Google Analytics on WordPress with Jetpack, the easiest way to make the most of this powerful tool.

Tip: If you’ve already installed and set up the Jetpack plugin for WordPress, scroll down to the ‘Find my Google Analytics measurement ID’ section!

1. Install Jetpack

You can install Jetpack directly from the WordPress Admin area. 

  1. Click on PluginsAdd New.
  2. Search for Jetpack.
  3. Click Install NowActivate.
  4. Click Set up Jetpack.

You’ll now connect your website to WordPress.com, which will enable you to take advantage of Jetpack’s features, like site stats. All you need to do is click Approve, and Jetpack will take care of everything else.

2. Select a Jetpack plan

Jetpack Stats is free to use and includes key stats for your WordPress site. However, you’ll need to invest in a paid Jetpack Complete or Security plan to connect Google Analytics to your WordPress site. These plans include additional features like real-time backups, spam prevention, and malware scanning

  1. Head to https://cloud.jetpack.com/pricing in a new browser tab. 
  2. Select a Jetpack plan.
  3. Enter the URL of your WordPress site and click Continue.
  4. Enter the login credentials for the WordPress user account you want to connect. 
  5. Complete the checkout process. At this point, Jetpack will prompt you to enable additional, helpful features. Choose the ones you want or manage them at a later date. Return to your WordPress Admin and click JetpackSettings. Then, navigate to the Traffic tab.
  6. Click Activate Site Stats

At this point, you can already view important information about your site through Jetpack Stats. Learn more about that here. 

Jetpack site stats example

But let’s see how to enhance this already powerful tool by connecting Google Analytics.

3. Connect Google Analytics 

Unlike adding Google Analytics to WordPress manually, you don’t need to copy and paste complicated code. All you need is the measurement ID. If you saved it when you signed up for Google Analytics earlier in this tutorial, now’s the time to pull it out! 

If you need to find your Google Analytics measurement ID, here’s how to do so: 

  1. Log in to Google Analytics and click Admin in the bottom left-hand corner of your main dashboard. 
  2. Click Property in the left-hand menu. 
  3. Click Setup Assistant in the right-hand menu.
  4. Go to Tag Installation and click Web.
  5. Click on your Google Analytics property.
  6. Copy the measurement ID. It’s a combination of letters and numbers like G-12345.

Now, you can add that ID to your site by following these steps: 

  1. Go to your WordPress dashboard.
  2. Go to JetpackSettingsTraffic
  3. Scroll to Google Analytics.
  4. Click Configure Your Google Analytics Settings. Clicking this option will redirect you to your WordPress.com dashboard. 
  5. Scroll to the Google Analytics section.
  6. Paste your measurement ID in the Google Analytics Measurement ID section. 
  7. Review and toggle any settings as desired. Learn more about your options here
  8. Click Save Settings.
entering tracking ID in Jetpack

And that’s all it takes to gain access to a wealth of information about your site.

How to view Google Analytics on WordPress

Now that you’ve completed the setup process, you’re ready to view information from Google Analytics on WordPress. All you have to do is go to Insights → Reports in your WordPress dashboard.

How to add Google Analytics to WordPress manually

The manual method is definitely the most complicated one because it requires working with code — a skill you might not have. It can be easy to make a mistake that causes your entire WordPress site to stop working. So, if you want to go down this route, it’s a good idea to back up your website before going any further. Jetpack VaultPress Backup can help you do that.

By using this tool, you can easily restore a full version of your site to the exact state it was in before it went down, even if you can’t access your WordPress dashboard at all.

Before you start, you’ll also need the Google Tag provided to you after you created your Google Analytics account. Note that this is longer and more complex than the measurement ID referenced earlier.

To find this, log in to your Google Analytics account. Click Admin in the bottom left-hand corner of the screen. Click Data Streams → Web in the Property column. Choose the stream for your site. 

Now, select View tag instructions → Install Manually. Copy the entire selection of code that appears, starting with <!– Google tag (gtag.js) → and ending with </script>.

Add your Google tag to WordPress

You’ll need to insert this tag into the <head> of every page on your site, which you can do using the functions.php file. If at all possible, you’ll want to make sure you’re using a child theme, which is essentially a “copy” of your theme that prevents you from losing any customizations when you run a theme update.

The best and safest way to access your functions.php file is through file transfer protocol (FTP). You can do this by using a FTP software like FileZilla, along with the FTP login credentials for your site. Typically, these are found in your hosting provider’s cpanel or other dashboard.

In FileZilla, enter the host, username, password, and port you found from your host.

entering ftp information in FileZilla

Then, you’ll see a list on the right side. This shows all of the files and folders on your server. 

example of the public_html folder viewed via FileZilla

Open public_html → wp-content → themes → yourtheme. Of course, if you’re using a child theme, open the child theme folder. Find the functions.php file and download it to your device.

Then, open the file in your text editing software of choice, like Notepad++ or TextEdit. At the bottom of the file, paste the following code:

<pre class="wp-block-syntaxhighlighter-code">

<?php

add_action('wp_head', 'wpb_add_googleanalytics');

function wpb_add_googleanalytics() { ?>

// Paste your Google tag here

<?php } ?>

</pre>

Remember to paste your Google tag where instructed above! Save the file once you’re done.

Remove the old functions.php file from your server and replace it with the updated version from your computer by dragging and dropping it to FileZilla. You should now be good to go! Navigate to your website and ensure that everything looks good and that you haven’t made an error when editing the file.

If, for any reason, there is a problem, you’ll need to restore a backup of your WordPress site.

But how do you know if the connection is working? It can actually take up to 24 to 48 hours to start showing site data within Google Analytics. But in the meantime, you can take these steps:

  1. Head back to Google Analytics.
  2. Click Reports → Realtime.
  3. Pay a visit to your WordPress site. 

If your tag is working correctly, you’ll see the Google Analytics page update to reflect your visit.

viewing active visitors on your site

Another option is to use Google’s Tag Assistant extension for Google Chrome. Simply install this tool in your browser and navigate to your website. Then, click the extension’s icon in your browser’s top toolbar, followed by the Enable button. Reload the page. 

Google Tag Assistant extension

This will show you any and all Google tags you have on your site, including one for Google Analytics, and will alert you to any problems. 

viewing Google tags

If you do run into issues, you can use this guide from Google to troubleshoot them.

Simple, yet powerful stats to grow your site

With Jetpack Stats, you don’t need to be a data scientist to see how your site is performing.

Get Jetpack Stats

Why install Google Analytics on WordPress with a plugin?

The problem with installing Google Analytics manually — apart from the complexity and risk — is that it only allows you to view WordPress data from within Google Analytics. You can’t see your site information directly inside of WordPress, so you’ll need to constantly switch between Google and WordPress.

There might also be an issue if you’ve used Google Analytics at some point previously, and now want to do so for your WordPress site. In the past, you probably used Google’s Universal Analytics system, which was the standard prior to 2020. 

Now, however, the standard is GA4, which uses a completely different interface than the one you might be familiar with. Of course, this can complicate things, especially if you just want to gain access to simple information.

Using a plugin like Jetpack will allow you to overcome those challenges and view Google Analytics on WordPress — the platform you already know how to use! Plus, it’s simple and easy to use, without requiring you to edit code.

Frequently asked questions about Google Analytics on WordPress

Here are answers to some common questions about Jetpack Stats and using Google Analytics with WordPress:

What is Google Analytics?

Google Analytics is a platform that anonymously tracks visitor behavior and aggregates that information so it’s useful to site owners and marketers. Google Analytics on a WooCommerce store, for example, can track the ultimate sources of sales revenue so marketers know which efforts provided the best return on investment. 

But Google Analytics can also tell site owners the pages and posts that are the most popular — in terms of number of visits, but also how long people stay on the page. You can figure out which traffic sources lead people to visit five pages instead of two pages on average (a measure of engagement). You can compare information over time to gauge the success of your site. Does your traffic increase? Are visitors coming back more than once? Have you improved your bounce rate by providing a better, more interesting experience for visitors? 

There are seemingly thousands of ways you can work with the data to get both basic and highly-advanced insights. Here are some of the things Google Analytics tracks: 

  • Visitor demographic information, like location, devices used, and interests
  • Customer behavior analytics
  • Top sources of traffic
  • User engagement trends
  • Goal completions, like adding products to a cart or signing up for an email list
  • The success of various marketing campaigns

What is Jetpack Stats?

Jetpack Stats is a tool developed by the creators of WordPress.com to meet the needs of WordPress websites. It generates simple analytics and information about your website, like visitor data and traffic sources. You can use Jetpack Stats to learn more about the people who engage with your content, where visitors come from in the world, what pages and posts are the most popular with your audience, and other valuable insights. 

Do I need Google Analytics to use Jetpack Stats?

No! Jetpack Stats is a standalone tool that generates information about your WordPress site without any need for Google Analytics. View data within WordPress via simple graphs and charts, and learn more about your visitors and traffic sources.

Can Jetpack Stats and Google Analytics work side by side?

Yes! You can use data generated by Jetpack alongside Google Analytics information to get a 360-degree view of your WordPress website. 

Whether you’re a small business owner, developer, or anyone else who manages a WordPress site, Jetpack Stats provides access to helpful statistics and analytical information to advance your goals.

Is Jetpack Stats free to use?

Yes, Jetpack Stats is free to use, and gives you great WordPress site data and information. 

If you want even more advanced information, you can connect your WordPress site to Google Analytics using a paid Jetpack plan like Jetpack Security or Jetpack Complete.

What other complementary tools does Jetpack offer?

Depending on your plan, Jetpack also provides tools that help you manage and protect your WordPress site, including:

Where can I obtain support for Google Analytics?

Google Analytics is a complicated tool that provides a lot of data that you might not need. If you run into problems, the Google Analytics support forum lets you share information with and get help from other users. 

Alternatively, you might decide to use Jetpack Stats. This is a simpler tool that is easier to navigate and understand. And it includes top-notch support from WordPress experts!

What about Do Not Track?

Do Not Track (DNT) is a feature in web browsers and websites that asks advertisers and other web software providers to not track individuals’ browsing habits. If you’ve enabled Google Analytics using Jetpack, you can force Google Analytics to honor any visitors with DNT enabled and not track their activity (i.e. post and page views) by adding the following code snippet to your site:

add_filter( 'jetpack_honor_dnt_header_for_wga', '__return_true' );

Learn more about adding code snippets to your site here.

What about WooCommerce analytics?

You can also use Jetpack Stats to view information about your WooCommerce store, including order data and trends. Google Analytics, which you can integrate using Jetpack, has additional ecommerce tracking capabilities

WooCommerce, however, also has ecommerce analytics that you can access by going to Analytics in your WordPress dashboard. From here, you can get information about revenue, orders, coupons, taxes, and more. 

Learn about your WordPress site visitors

Regardless of the kind of site you run, you probably want to learn more about who’s interacting with it and how. Jetpack Stats can provide you with essential information to measure the progress of your efforts and keep tabs on what’s working and what needs improvement. Plus, you can use Jetpack to quickly integrate Google Analytics when you’re ready for more detailed data.

Get started with Jetpack Stats.

This entry was posted in Analytics, Grow. Bookmark the permalink.

Rob Pugh profile
Rob Pugh

Rob is the Marketing Lead for Jetpack. He has worked in marketing and product development for more than 15 years, primarily at Automattic, Mailchimp, and UPS. Since studying marketing at Penn State and Johns Hopkins University, he’s focused on delivering products that delight people and solve real problems.

Simple, yet powerful stats to grow your site

With Jetpack Stats, you don’t need to be a data scientist to see how your site is performing.

Get Jetpack Stats

Have a question?

Comments are closed for this article, but we're still here to help! Visit the support forum and we'll be happy to answer any questions.

View support forum
  • Enter your email address to follow this blog and receive news and updates from Jetpack!

    Join 112.8K other subscribers
  • Browse by Topic