3 methods to set up Google Analytics on WordPress​

Setting up Google Analytics on WordPress – 3 easy ways to track the behaviour of your site visitors.
Google Analytics to WordPress​ - Welcome to the Google Analytics screen

Google Analytics to WordPress - 3 methods to add.

Discover a powerful tool to help you improve your understanding of how visitors reach your pages and use your WordPress-powered website.

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

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

There are two types of Google Analytics code.

You may be familiar with the Google Universal Analytics (UA) code. This has been discontinued and replaced by Google Analytics 4 (GA4).

GA4 is much more adaptive and applies to websites or apps, while Google UA can only be applied to websites and will no longer be used.

Google Analytics 4 has released a new audience report.

Setting up Google Analytics on WordPress

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

You will be prompted to sign in with your Gmail account. Once you’ve done that, you will enter the system.

Choose the button that initiates the measurement.

Google Analytics Property Setup screen

The next screen will prompt you to create an account name. You can track more than one website under a single account, so you may want to use something broad, like your business name.

 

Google Analytics Property Setup screen

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

The following screen will request information about your business and how you intend to use Google Analytics.

Click on the agreement terms and select email notifications, and you will be taken to the admin dashboard.

Google Analytics Property Setup screen

Afterward, you’ll be able to set up the data stream.

When adding Google Analytics to a WordPress site, select “web stream.”

Then, you’ll add the URL of your site and the site name.

Once you click the “Create stream” button, you will see the stream name, stream URL, stream ID, and measurement ID.

The measurement ID is the code you’ll use to add to your website.

Google Analytics data flow screen

Linking Google Analytics to WordPress

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

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

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

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

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

1. Използване на плъгин за свързване на Google Analytics с WordPress

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

Google Analytics for WordPress by MonsterInsights is the most popular and makes it easy to add your Google Analytics code to your site.

The free version should work perfectly unless you want advanced tracking and reporting features. Then you would want to upgrade to the pro version (paid).

Plugin MonsterInsights

  • Step 1: Install and activate the MonsterInsights plugin.
  • Step 2: Launch the setup wizard to fill in your website information and click the Connect MonsterInsights button. This will guide you through several setting pages that need to be preselected for your configuration.
  • Step 3: Next, you’ll be prompted to log in to your Gmail account, requesting permission to access your Google account.
  • Step 4: Click Allow, and then the Google Analytics account it will connect to will be displayed.
  • Step 5: Press Complete Connection to link to your Google Analytics account. It will finish by offering an upgrade to the Pro version, but you can choose the link at the bottom to complete the installation without an upgrade.

Now you’re all set, and you’ll see Insights in the WordPress dashboard. Reports, settings, and all other selected tools will now be visible in your WordPress dashboard.

2. Using the Header/Footer script plugin to connect Google Analytics to WordPress

The second way to install your Google Analytics tracker is with a header/footer script plugin.

This method is especially useful if you want to track different metrics on different pages, as it can be applied to specific pages and/or the entire website.

WPcode

WPCode Header and Footer Code + Custom Code Fragments – WordPress Code Manager is the most popular plugin for inserting header and footer code with over 1 million users. Another way to add Google Analytics to WordPress.

  • Step 1: Install the header and footer script plugin on your WordPress site.
  • Step 2: In your Google Analytics account, click on Tracking Instructions, and then select the Manual Installation section.
  • Step 3: Copy the Google Tag code.
  • Step 4: In your WordPress dashboard, you’ll find the Code Snippets plugin in the left navigation menu.
  • Step 5: Select Header and Footer from the dropdown menu and paste your code into the Header section.
  • Step 6: Click Save Changes.

code snippets for wordpress

header screen plugin

  • 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 that page. Click Update to save your changes. This step is not necessary when adding Google Analytics to WordPress.

single page header code

3. Add Google Analytics code directly to the header.php file to Add Google Analytics to WordPress

If you’re comfortable working directly in your theme’s code, this is another option for adding your Google Analytics code. Keep in mind that you are directly modifying theme files, so if you change or update your theme, you will lose your Google Analytics code and will need to add it again every time you update or change the theme.

  • Step 1: In your WordPress dashboard, go to Appearance > Theme File Editor.
  • Step 2: Choose your main theme and select header.php.
  • Step 3: Copy and paste the code just before the closing </head> element.
  • Step 4: Click Update File to save your changes.
 
 

Access the WordPress theme file editor

WordPress theme file editor

Checking your Google Analytics Tags

After you have installed your Google Analytics tracking code on your website, you can use the Tag Assistant (Legacy) Chrome Extension to verify whether your Google Analytics tag is installed and working correctly.

Simply install the Chrome extension in your browser, open the WordPress site where you’ve installed Google Analytics, and it will tell you which tags are present on the site and whether there are any errors.

Tag Assistant Legacy от Google

After Google Analytics is Installed on your WordPress site

Once your Google Analytics tag is installed, you can access the dashboard through the Google Analytics website.

Alternatively, if you chose the MonsterInsights plugin method to install Google Analytics on your WordPress site, you can view reports and data from the WordPress dashboard.

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

Adding the Google Analytics tag to your WordPress site is easy, using one of these three methods:

  • Google Analytics plugin (such as MonsterInsights).
  • Header/Footer script plugin (like WPCode).
  • Adding it directly to the header.php file of your theme.

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

It’s worth noting that Google Analytics cannot retroactively collect data, so it’s essential to add Google Analytics to your website sooner rather than later to avoid missing out on data.

Victoria Pencheva
About the author
Call Now Button