In order to have a successful website it’s important to understand how your audience interacts with and finds your website. The best way to do this is to analyze your website’s traffic data. Google Analytics provides this service for FREE.
In this step-by-step guide, we will discuss why Google Analytics is important and show how to add Google Analytics to WordPress easily.
NOTE: TarttWeb is reader-supported. This means that we may earn a small commission at no additional cost when you make a purchase through referral links on our site.
If you’d like to jump to the section you’re looking for, a hyperlinked table of contents is available.
What is Google Analytics and Why is it Important?
Google Analytics is a free service offered by Google that lets website owners and admin’s view data related to their website traffic and activity.
This service can be used for SEO and marketing purposes to understand where your website traffic is coming from, what pages were visited, what device they’re using, the browser they’re using, and demographics such as age group, gender, country, city, and interests.
This is important because understanding how users find your website and how they interact with your website once they arrive will help you better understand your audience.
You can use the data from Google Analytics to spot trends in user activity and how they interact with pages and posts. This will allow you to make informed decisions based on what your site visitors are actually doing.
How to Sign Up for a Free Google Analytics Account
To get started using Google Analytics with your WordPress website you will first need to create a free account. All you need is a Google or Gmail account to sign up. Don’t worry it’s nothing too complicated, just follow the step-by-step instructions below to create your free Google Analytics account.
Step 1: Visit the Google Analytics website to sign up.
The first step is to visit the Google Analytics website and sign up for an account. Once you are on the site, look for the Get started today button and click on it.
Then you will be asked to sign in to your Google account. If you already have Google or Gmail account you can use either account. Otherwise, you will need to create a new Google account.
Step 2: Sign up for a Google Analytics account
After you have signed in with your Google or Gmail account, you will be directed to the Google Analytics welcome screen like the one below.
This is where you will sign up for your Google Analytics account. To get started, go ahead and click on the Start measuring button.
You will then be directed to the account creation page where you will be asked to provide an Account name. Your account name is used internally, so this can be anything meaningful related to your business such as your business name.
You will also see multiple Data Sharing Settings. These settings give you control over sharing your Analytics data. If you are unsure about the Data Sharing Settings you can leave the boxes checked. To continue scroll down and click on Next.
Step 3. Create a Google Analytics property
NOTE: There are two versions of Google Analytics which are Universal Analytics and Google Analytics 4 (GA4). Universal Analytics will become obsolete on July 1, 2023. So creating a GA4 property from the start will be in your best interest.
Now it’s time to set up a property. Enter a Property name. This can be your website name. Then select your Reporting time zone and Currency. Once complete click on the Next button.
Next, you’ll need to fill in some information about your business. Start by selecting the industry your website operates in by selecting an option from the Industry category dropdown menu then choose a Business size.
After that scroll down and select how you plan to use Google Analytics with your business. You can choose one, multiple, or all options that meet your needs. When you have finished click on the Create button
Once you click on the Create button, a popup window will open with the Google Analytics Terms of Service Agreement.
Read through the service agreement and check the I also accept the Data Processing Terms as required by GDPR box then click the I Accept button.
Next, you will be redirected to the Google Analytics interface and be shown another popup window with email communication options. Click the checkboxes for emails you would like to receive then click the Save button.
NOTE: After you click the Save button you should see a Take a Tour of Google Analytics 4 popup. We recommend taking the tour to get familiar with the interface.
Step 4. Set up a Data Stream for your Website
In this step, we will need to set up a data stream to collect data from your website. Start by selecting Web as your platform since this is for a WordPress website.
Next, you’ll need to enter your Website URL and a Stream name.
By default, Google Analytics will have the Enhanced measurement option enabled. This allows you to track Page views, Scrolls, Site searches, and more.
When you’re finished, click on the Create stream button.
After that, you will see a new page that displays your STREAM NAME, STREAM URL, STREAM ID, MEASUREMENT ID, and the Enhanced measurements it will record.
You can also see the different ways that Google Analytics can be added to your WordPress website by clicking on View tag instructions at the top highlighted in orange or by scrolling down and clicking on View tag instructions at the bottom.
After that, you will see two options, Install with a website builder or CMS and Install manually.
If you click on the Install manually you will see a block of code which is the Google tracking code. You will need to copy this code if you plan to install Google Analytics manually. Just leave the browser tab open so you can copy it easily when you need it.
Alright, you now have a new Google Analytics account and a data stream set up. The next step is to add it to your WordPress website so you can start recording activity.
How to Add Google Analytics to WordPress
In the following sections, we will show you how to add Google Analytics to WordPress with a plugin, how to add Google Analytics to WordPress without a plugin, and how to add Google Analytics to WordPress using code.
NOTE: You only need to use one of the following methods on your website to avoid double tracking of activity in your Google Analytics account.
Alright, let’s get started.
How to Add Google Analytics to WordPress with a Plugin
In this part of the guide, we will show you how to add Google Analytics to WordPress using Google Site Kit, a WordPress plugin officially released by Google.
With Google Site Kit you can get insights about how people find and use your website, including how to improve and monetize your content right from your WordPress dashboard.
There are lots of other great WordPress Analytics plugins available. And once you are familiar with adding Google Analytics to WordPress with one plugin, it is often pretty straightforward if you want to switch to another plugin.
Step 1. Download, Install, & Activate Google Site Kit
From the main navigation of your WordPress admin area hover with your cursor over Plugins and click on Add New. Then in the search box on the top-right search for Site Kit.
Now click the Install button. Once the plugin has finished installing, click on Activate.
Step 2. Setup Google Site Kit
After activating the plugin, you should see a success message at the top of the page. Click on the Start setup button to proceed.
After that select Connect Google Analytics as part of your setup, then click on the Sign in with Google button.
Next, you will be directed to a new screen asking you to Choose an account to continue to Site Kit. Then check the boxes to grant Site Kit the necessary permissions, then click on Continue.
Now click on the Verify button to verify your site ownership.
Then click on the Allow button to Turn on metrics in your dashboard.
Next, click on the Set up button to set up Google Search Console.
After that click on the Next button to Set up Google Analytics.
Finally, for the last part, you need to select your Google account to connect to Analytics. Then select the property that we set up in the previous ‘How to Sign Up for a Free Google Analytics Account’ section and click on the Configure Analytics button.
If there are any additional permissions required click the Proceed button to continue and go through any additional steps to finish up.
Once complete you will see a success message and be redirected to your WordPress site.
That’s it, you have now configured Site Kit and have successfully connected to Google Analytics.
How to Add Google Analytics to WordPress Without a Plugin (Manually)
Before we get started it’s important to note that adding Google Analytics manually will not show any stats or data in your WordPress dashboard. It will only report information to Analytics. To see your website stats, you will need to log into your Google Analytics account.
Also in this section, we show you how to add Google Analytics to WordPress without a plugin, specifically without an analytics plugin. You will need to add a plugin that inserts code snippets into your website.
More advanced users can skip to the next section: how to add Google Analytics to WordPress using code.
Alright, let’s get started.
Step 1. Locate Your Google Analytics Tracking Code
To manually connect your WordPress site to Google Analytics you need to locate your tracking code. If you followed our: How to Sign Up for a Free Google Analytics Account section of this guide, you should have it available. If not, that’s OK. It’s pretty easy to find.
First, sign into your Google Analytics account.
Second, locate your tracking code, by clicking on the Admin Cog icon on the bottom left. Then click on Tracking Info → Tracking Code underneath Property Access Management. You will then see your Tracking ID and the tracking code.
Step 2. Add the Tracking Code to Your Site Header
Next, log into your WordPress admin area. Now you need to install a plugin to add the code to your site. So, from the main navigation on the left, hover over Plugins, then click on Add New.
Now search for Insert Headers and Footers, then Install and Activate it.
After the plugin has finished installing, hover over Settings on the main dashboard and click on WP Headers and Footers.
Now paste your Google Analytics Tracking Code into the Scripts in Header section. Then scroll to the bottom and click on Save Changes and you’re done.
To see your Analytics data, you will need to log into your Google Analytics account. But be advised that this can take 24 to 48 hours before you start seeing anything, so be patient.
How to Add Google Analytics to WordPress Using Code.
This section is for advanced users who know how to access their WordPress website’s files and edit code. This also only works if you have a custom WordPress theme or a child theme of a parent theme. Otherwise, your changes will be overwritten every time your theme is updated.
Step 1. Copy your Google Analytics Tracking Code
First, you need to locate your tracking code also known as your global site tag then copy it from your Google Analytics property. If you need help finding it take a look at the previous section.
Step 2. Insert Code into Your Functions.php
Next, you’ll need to open your WordPress site’s functions.php file. You can do this via FTP, a popular IDE (we like Jet Brains phpStorm), or the Theme Editor in the WordPress admin area.
Step 3. Add Your Tracking Code
Now you need to create a function in your functions.php file that contains your tracking code. Then add an action telling WordPress to add it to your header. Below is an example:
Finally, save your functions.php file and check your site. Open the inspector of your browser and look in the <head> section to verify its loading.
So, you made it to the end of our, how to add Google Analytics to WordPress guide and hopefully didn’t have too much trouble following along. So where do you go from here?
We recommend getting familiar with Google Analytics and how it works. Probably one of the best places to start is Google Analytics support where you can read the documentation and browse community questions and answers.
After that, you should start analyzing your data to see how you can improve your website’s traffic and user engagement. You’ll also want to get Google Search Console set up as well as Bing Webmaster Tools.
Alright, that’s it. Good luck!
If, you found this article helpful, let us know in the comments section, follow us on social media, or subscribe to our newsletter for more. If you need a guide or article written, contact us and select article request in the dropdown.