When it comes to optimizing and properly marketing a website, few things are as valuable as knowing your audience and how they interact with your content. This information can inform nearly every business decision you make. That’s why it’s a smart idea to set up Google Analytics in WordPress.
Google Analytics is one of the best solutions on the market for gathering data about your website’s visitors. Many users struggle to integrate Google Analytics with WordPress, but thanks to plugins, it can actually be a simple task.
In this article, we’ll explore Google Analytics and its benefits. Then we’ll walk through three different methods for adding this key tool to your WordPress site, including two completely code-free solutions. Let’s get started!
📚 Table of contents:
An introduction to Google Analytics
Google Analytics is a powerful platform that enables users to dive deep into their website’s audience, traffic patterns, and more. It’s easy to use and, perhaps best of all, free.
Google Analytics works by embedding a tracking code on your site (usually in the header, so that it’s present on every page). It then uses that code to log details about each visitor to your site, including:
- Where they arrive from
- Which pages they land on and leave from
- The pages they visit and how long they spend there
- Their demographic information (such as age, gender, and interests)
- Other activities (for example, clicking on specific links)
You can also segment this data for even finer detail. The result is a powerful portrait not just of the volume of traffic your site receives, but also the behavior of those visitors. This information can then be used to inform all manner of business decisions, from marketing strategy to which blog posts you’ll feature on your home page.
Three ways how to set up Google Analytics in WordPress
It’s relatively easy to set up Google Analytics in WordPress. However, if you’ve never dealt with code or dived into the HTML that makes up your site, adding the tracking code can be intimidating. For that reason, several plugins exist to simplify the process by automatically embedding that code.
In the following sections, we’ll walk through setting up this integration using two of the best WordPress Google Analytics plugins, as well as by adding the code manually. Note that these methods all assume you’ve already signed up for a Google Analytics account and completed the initial setup process – including setting up a web property to add your site to Google Analytics. If you haven’t done that yet, head over to the Google Analytics site and sign up first.
1. Install Google Analytics using the OrbitFox plugin
OrbitFox is a powerful, multifunctional, and free plugin developed here at Themeisle. When compared to MonsterInsights, it offers a much broader set of features, including Gutenberg blocks, a site optimizer, menu icons, and much more. It’s ideal for users who want an all-in-one solution to better their WordPress sites.
To get started with the Google Analytics functionality in OrbitFox, head to your WordPress dashboard and install the plugin. Once it’s activated, navigate to OrbitFox > General Settings:
Locate Analytics Integration in the list of options and toggle the Activate switch. The page will automatically scroll down to reveal a new Authenticate with Google button.
Click on it, and then select your Google account from the popup and approve the requested permissions:
You’ll be taken back to the OrbitFox settings screen, and a new section will appear at the bottom:
Select the appropriate tracking code for your website from the drop-down menu and click on Save. At this point, you’re done: the code will be automatically added to your site, and you can view your stats from the Google Analytics website.
2. Install Google Analytics using the MonsterInsights plugin
The second method we’ll explore is using the MonsterInsights WordPress plugin, a popular solution for implementing Google Analytics in WordPress. In addition to helping you set up Google Analytics, the plugin also lets you view important statistics without leaving your WordPress dashboard.
To get started, head to your WordPress dashboard and install and activate the plugin. After activation, you’ll be presented with a welcome screen. Scroll down a bit until you see the Launch the Wizard! button:
This button opens a setup wizard that helps walk you through the process. First, you’ll be asked to select a category for your site, which determines some of the default settings you’ll start with.
After that, you’ll be asked to Connect MonsterInsights, which is what syncs your site with Google Analytics:
After that, you’ll be asked to enter your Google Analytics account information (or choose the associated Google account from a list):
Once that’s done, give MonsterInsights the requested permissions:
Then, you can choose your website from a list of Google Analytics web properties. If you don’t see your site, remember that you need to set up a property in Google Analytics first:
⚠️ Note that it can take up to 24 hours for the data to start flowing between the two services. However, once it does, you can view your site’s stats from either the Google Analytics website or your WordPress dashboard.
The basic MonsterInsights plugin is free to use. You can also upgrade to a premium version, which starts at $99.50 per year. This offers some additional features such as more advanced dashboard tools and integrations with other WordPress plugins.
3. Install Google Analytics in WordPress manually
The final option we’ll cover here is the most basic, but also the most complicated to implement: manually adding the required tracking codes to your WordPress site. If you go with this approach, it’s essential that you use a WordPress child theme. Otherwise, your Google Analytics code will be overwritten every time you update your theme.
In addition, since you’ll be making changes to your website’s core files, it’s a good idea to back up your site before getting started.
To add the Google Analytics tracking code to your WordPress theme manually, you’ll need a piece of code known as the “Global Site Tag.” You can find this in your Google Analytics admin dashboard. Locate Tracking Info from the list of options, and then select Tracking Code:
On the next page, you’ll be presented with your Tracking ID, and below that you’ll find the code you need:
Copy that code and paste it somewhere safe (or just leave the tab open).
Now, head back to your WordPress dashboard and navigate to Appearance > Theme Editor. This is a built-in code editor for the files that comprise your WordPress theme.
In the sidebar to the right, locate the file labeled Theme Header (header.php) – make sure you choose the file from your child theme. If you don’t see a
header.php file in your child theme, you can add it by manually copying it from the parent theme folder to the child theme folder. Click on this file to open it in the main editor window:
Paste the Global Site Tag you copied earlier into this file, directly below the opening
<body> tag. Click on Update File to save the changes. You’ve now added the Google Analytics tracking code manually!
Frequently asked questions about Google Analytics and WordPress
Before we wrap up, let’s address some of the most frequently asked questions about using Google Analytics on your WordPress site.
Does Google Analytics work with WordPress?
Yes! There are multiple ways to integrate Google Analytics with WordPress, but all end with the same result: your WordPress site’s stats will be tracked and aggregated in the Google Analytics dashboard.
How do I use Google Analytics in WordPress?
First, you’ll need a free Google Analytics account. Then you can integrate that account with your website, using one of several methods.
The simplest way to use Google Analytics with WordPress is via a plugin. There are several options available, one quality solution is OrbitFox. It’s a free plugin that offers simple Google Analytics integration and several other features that are useful for any WordPress site. These include content optimization and additional blocks for the WordPress Editor.
You can also implement Google Analytics on your WordPress site manually, by copying and pasting some code into your theme files. However, this method is riskier and less reliable than using a plugin.
How do I add Google Analytics to my free WordPress blog?
You can use Google Analytics no matter what type of website you have. Whether you’re running a free blog, a membership site, or an eCommerce store, you can use the methods listed above to set up Google Analytics and track your visitors.
What is the best Google Analytics plugin for WordPress?
We recommend OrbitFox or MonsterInsights to set up Google Analytics on WordPress. The former is excellent for simple, straightforward integration. It is free and offers numerous features in addition to Google Analytics integration. These include a content optimizer, as well as modules for the Block Editor and various page builders.
Either plugin will work just fine for Google Analytics integration. Choosing one is simply a matter of weighing your needs versus the cost.
Whether your website is a hobby or a key business asset, knowledge is power. Few platforms offer the amount of knowledge that Google Analytics does, and integrating it with your WordPress website can help you take your traffic and revenue to the next level.
There are several ways to set up Google Analytics in WordPress. You can opt for a plugin such as MonsterInsights or OrbitFox, or you can go the DIY route and add the integration manually by editing theme files as long as you use a child theme. Either way, you’ll get access to some of the best analytics on the market combined with the power of WordPress.
Once you’ve added Google Analytics to your WordPress site, we also have some other guides to help you get the most from Google Analytics:
Do you have any questions about using Google Analytics with WordPress? Let us know in the comments section below!