Welcome to the Google Analytics screen

How to Add Google Analytics to WordPress

Google Analytics is a free comprehensive tool that allows you to track your web traffic and data.

Google Analytics will show you how many people visit your website, individual pages, conversions and how people interact with your content. This data is essential for optimizing your website.

There are two types of Google Analytics codes.

You’re probably used to Google Universal Analytics (UA) code. This will be phased out and replaced by Google Analytics 4 (GA4).

GA4 is more customizable and applies to websites or applications, while Google UA can only be applied to websites.

Set up Google Analytics on your website

The first thing you need to do is set up a free Google Analytics account.

You will be prompted to log in with your Gmail account. After doing this, you will be logged in.

Select the button that says “Start Measurement”.

Google Analytics screenshot, August 2022Welcome to the Google Analytics screen

The next screen will let you create an account name. You can track multiple sites under one account, so you may want to use something broad, such as your business name.

Google Analytics account setup screenGoogle Analytics screenshot, August 2022Google Analytics account setup screen

Next, you’ll want to set properties. This should include your website name, time zone, and the currency in which the business is located.

The next screen will ask about your business and how you plan to use Google Analytics.

Click on Terms of Agreement and select Email Communication and you will be taken to the Admin Dashboard.

Google Analytics Asset Settings ScreenGoogle Analytics screenshot, August 2022Google Analytics Asset Settings Screen

Next, you’ll want to set up the data flow.

When adding Google Analytics to your WordPress site, you need to select “Web Streaming”.

Next, you’ll add your site’s URL and site name.

once you hit Create flow button and you will see the Stream Name, Stream URL, Stream ID and Measurement ID.

The Measurement ID is what you will use to add to your website.

Google Analytics data flow screenGoogle Analytics screenshot, August 2022Google Analytics data flow screen

Add Google Analytics to your WordPress site

Google Analytics can be added to any WordPress site in three different ways.

The best option for you will depend on how comfortable you are with making changes to your website code.

The first option uses a WordPress plugin to add Google Analytics to your website without coding.

The second option uses a WordPress plugin and requires a small amount of code to be copied and pasted.

The third option requires you to edit the code in your website’s theme file.

1. Using the Google Analytics Plugin

The easiest way to add your Google Analytics tag code to WordPress is to use a plugin.

Google Analytics for WordPress from MonsterInsights is the most popular and allows you to easily add Google Analytics code to your website.

Unless you need advanced tracking and reporting features, the free version should work just fine. Then you’ll want to upgrade to the pro version.

MonsterInsights pluginImage via WordPress.org, August 2022MonsterInsights plugin
  • Step 1: Install and activate the MonsterInsights plugin.
  • Step 2: Launch the wizard to fill in the information about your website, then click the Connect MonsterInsights button. This will take you through a few pages of settings that should be pre-selected for your setup.
  • Step 3: Next, you will be prompted to log in to your Gmail account, asking for permission to access your Google account.
  • Step 4: Click “Allow”, then it will display the Google Analytics account to connect.
  • Step 5: Click Complete Connection to connect to your Google Analytics account. It will be done by offering a Pro upgrade, but you can select the link at the bottom to complete the installation without upgrading.

You are all set now and you will now see Insights in your WordPress dashboard. Reports, settings and any other selected tools are now visible in the WordPress dashboard.

2. Use the header/footer script plugin

The second way to install Google Analytics tags is to use the Header/Footer plugin.

This method is especially useful if you want to track different metrics for different pages, as it can be used for specific pages and the entire site.

WPCode pluginImage via WordPress.org, August 2022WPCode plugin

WPCode Insert Header & Footer + Custom Code Snippets – WordPress Code Manager is the most popular plugin for inserting header and footer code with over 1 million users.

  • Step 1: Install the Header and Footer plugin on your WordPress site.
  • Step 2: In your Google Analytics account, click the tag description and select the Manual Installation tab.
  • Step 3: Copy the Google tag code.
  • Step 4: In your WordPress dashboard, you will see the Code Snippets plugin on the left navigation menu.
  • Step 5: Select Header & Footer under the drop down menu and paste the code into the header section.
  • Step 6: Click Save Changes.
code snippet for wordpressImage via WordPress.org, August 2022code snippet for wordpress
Header Footer Plugin Screen Image via WordPress.org, August 2022Header Footer Plugin Screen
  • Optional step: To add code to a specific page or post, select the page or post and scroll to the bottom. Add the appropriate Google Analytics code to the header section of this page. Click Update to save your changes.
Header and footer code on a single page Image via WordPress.org, August 2022Header and footer code on a single page

3. Add the Google Analytics code snippet directly to the Header.php file

This is another option for adding Google Analytics code if you prefer to work directly in the theme code. Remember that you are changing the theme file directly, so if you change or update your theme you will lose your Google Analytics code and will need to re-add it every time you update or change your theme.

  • Step 1: In your WordPress dashboard, go to appearance > Theme file editor.
  • Step 2: Select the parent theme and header.php.
  • Step 3: At the end Copy and paste the code before the element.
  • Step 4: Click Update File to save the changes.
Access the theme file editor in WordPress Image via WordPress.org, August 2022Access the theme file editor in WordPress
WordPress Theme Files, August 2022
WordPress Theme File Editor Image via WordPress.org, August 2022WordPress Theme File Editor

Verify your Google Analytics tab

Once you have Google Analytics tags installed on your website, you can use the Google Chrome extension’s Tag Assistant (Legacy) to check that your Google Analytics tags are installed and working properly.

Just install the Chome extension on your browser, navigate to your WordPress site with Google Analytics installed, and it will tell you what tags are on your site and if there are any errors.

Google's Tag Assistant LegacyScreenshot by author, August 2022Google's Tag Assistant Legacy

After installing Google Analytics on your WordPress site

After installing the Google Analytics badge, you can view dashboards through the Google Analytics site.

Alternatively, if you chose the MonsterInsight plugin method of installing Google Analytics on your WordPress site, you can view reports and data directly in your WordPress dashboard.

Google Analytics is a powerful tool that can help you understand how your visitors come to and use your website, how your pages convert, how many users visit your website, and more.

Adding Google Analytics tags to your WordPress site is easy using one of three methods:

  • Google Analytics plugins (eg MonsterInsights).
  • Header/footer plugins (eg WPCode).
  • Add directly to the theme header.php file.

You can use data from Google Analytics to gain valuable insights into your website traffic, which will allow you to make improvements.

It’s worth noting that Google Analytics cannot collect data retrospectively, so it’s important to add Google Analytics to your website as early as possible to avoid losing any data.

More resources:

Featured Image: Andrey_Popov/Shutterstock

window.addEventListener( ‘load’, function() {
setTimeout(function(){ striggerEvent( ‘load2’ ); }, 2000);

window.addEventListener( ‘load2’, function() {

if( sopp != ‘yes’ && addtl_consent != ‘1~’ && !ss_u ){


if( typeof sopp !== “undefined” && sopp === ‘yes’ ){
fbq(‘dataProcessingOptions’, [‘LDU’], 1, 1000);
fbq(‘dataProcessingOptions’, []);

fbq(‘init’, ‘1321385257908563’);

fbq(‘track’, ‘PageView’);

fbq(‘trackSingle’, ‘1321385257908563’, ‘ViewContent’, {
content_name: ‘add-google-analytics-wordpress’,
content_category: ‘analytics-data seo wp’

Leave a Comment

Your email address will not be published.