Digital Marketing

How To Add Google Analytics To WordPress

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

Google Analytics will show you the number of people visiting your site, 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 code.

You may be used to Google Universal Analytics (UA) Code. This command is changed and replaced with 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 want to do is set up a file Google Analytics the account.

You will be prompted to log in with a file gmail the account. Once you do that, you will be logged in.

Select the button that indicates start measurement.

Screenshot from Google Analytics, August 2022

The next screen will make you create an account name. You can track more than one site under one account, so you might want to use something broad, like your business name.

Google Analytics account setup screenScreenshot from Google Analytics, August 2022

Next, you will want to set up properties. This should include the name of your website, the time zone, and the currency used for that business’s location.

The next screen will ask a little bit about your business and how you intend to use Google Analytics.

Click on the Terms of Agreement and select Email Communications, and you will be taken to the Administrator Dashboard.

Google Analytics property setup screenScreenshot from Google Analytics, August 2022

Next, you will need to set up the data stream.

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

You will then add your site URL and site name.

Once you click on file Create a stream button, you will see the name of the stream, the URL of the stream, the stream ID, and the measure ID.

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

Google Analytics data flow screenScreenshot from Google Analytics, August 2022

Add Google Analytics to your WordPress site

There are three different ways to add Google Analytics to any WordPress site.

The best option for you will depend on your comfort level with making changes to your website’s code.

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

The second option is using a WordPress plugin with a small amount of code required to be copied and pasted.

The third option requires you to modify the code in your website’s theme files.

1. Using the Google Analytics Plugin

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

Google Analytics for WordPress from MonsterInsights It is the most popular and easiest to add Google Analytics code to your site.

The free version should work perfectly fine unless you want advanced tracking and reporting features. Then you may want to upgrade to PRO version.

MonsterInsights pluginImage from WordPress.org, August 2022
  • Step 1: Install and activate the MonsterInsights plugin.
  • Step 2: Run the wizard to fill in information about your location and hit the Connect MonsterInsights button. This will take you through a few pages of settings that need to be pre-selected for your setup.
  • Step 3: Next, you will be asked to sign in to your Gmail account, and ask for permission to access your Google account.
  • Step 4: Click on Allow, then it will display the Google Analytics account to be connected to.
  • Step 5: Tap on Full Connect to connect to your Google Analytics account. It will end up offering an upgrade to the Pro version, but you can select the link at the bottom to finish the installation without upgrading.

You are all set, 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 a header/footer script plugin

The second way to install the Google Analytics tag is with a file Header/Footer plugin.

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

WPCode pluginImage from WordPress.org, August 2022

WPCode insert headers and footers + custom code snippets – WordPress code manager It is the most popular plugin for inserting header and footer code with over 1 million users.

  • Step 1: Install a file Headers and footers plugin on your WordPress site.
  • Step 2: In your Google Analytics account, click on Tagging Help, then select the Install Manually tab.
  • Step 3: Copy the Google tag code.
  • Step 4: On your WordPress dashboard, you will see the Code Snippets plugin in the left navigation menu.
  • Step 5: Select Header & Footer at the bottom of the dropdown menu and then paste your code in the Header section.
  • Step 6: Click on Save Changes.
Code snippets for WordPressImage from WordPress.org, August 2022
Header-Footer plugin screen Image from WordPress.org, August 2022
  • Optional step: To add an icon to a specific page or post, select the page or post and scroll down. Add the appropriate Google Analytics code in the header section of that page. Click Update to save the changes.
One page header footer code Image from WordPress.org, August 2022

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

If you are comfortable working directly in your theme code, this is another option for adding your own Google Analytics code. Keep in mind that you are changing theme files directly, so if you change or update your theme, you will lose your Google Analytics code and will need to re-add it each time you update or change your theme.

  • Step 1: On your WordPress dashboard, go to appearance > Theme file editor.
  • Step 2: Select the parent topic and header.php.
  • Step 3: Copy and paste the code before the closing element directly.
  • Step 4: Click on Update file to save the changes.
Access to the theme file editor in WordPress Image from WordPress.org, August 2022
WordPress Theme Files, August 2022
WordPress theme file editor Image from WordPress.org, August 2022

Check your Google Analytics tags

Once you have your Google Analytics tag installed on your website, you can use Tag Assistant (old) by Google Chrome Extension To verify that the Google Analytics tag is installed and working correctly.

Simply install the Chome extension on your browser, go to the WordPress site where you have Google Analytics installed, and it will tell you what tags are on the site and if there are any errors.

Tag Assistant Legacy from GoogleScreenshot by the author, August 2022

Once you have Google Analytics installed on your WordPress site

your one time Google Analytics tag Installed, you can view the dashboard through the Google Analytics website.

Alternatively, if you select the MonsterInsight plugin method to install Google Analytics on your WordPress site, you can view reports and data from directly within your WordPress dashboard.

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

Adding a Google Analytics tag to your WordPress site is simple, using one of the following three methods:

  • Google Analytics plug-in (eg MonsterInsights).
  • Header/Footer plugin (such as WPCode).
  • Add directly to the header.php file the attribute.

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

It should be noted that Google Analytics cannot collect data retroactively, so it is important to add Google Analytics to your website sooner rather than later to avoid losing any data.

More resources:

  • Google Tag Manager: A GA4 Guide for Beginners
  • 11 Google Analytics reports you may not know
  • 13 of the best Chrome extensions for digital marketing and SEO

Featured image: Andrey_Popov/Shutterstock

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button