How to Install Google Analytics in WordPress for Beginners

How to Install Google Analytics in WordPress for Beginners

The easiest way to understand the audience is through traffic stats, and this is what Google Analytics provides without any cost.

The analytics tells the geographical location of the visitors, the browser used by the user to visit the site, and other information like screen resolution, JavaScript support, Flash support, language, and more.

This data is extremely useful in numerous ways. While building a custom website design, the user data can be used to make sure that the website site will be compatible with the audience.

How do people interact with your content?

Google Analytics shows how users read the site’s content. It displays the percentage of the user who clicked on which link on the website.

By observing the user interactivity, you can improve the content for the users. You can work on the strategies and avoid methods that don’t work.

How to Sign up with Google Analytics

Google Analytics is freely available and then sign-up Google or Gmail account.

Step 1:  Visit the Google Analytics website to sign up and then click on the ‘Get started today’ button.

Google Analytics

Next, you will be asked to login with your Google account. If you already have a Google or Gmail account, then you can use that to sign in. Otherwise, you can go ahead and create a Google account for yourself.

Google-analytics-sign-in

Step 2: After you have a sign-in with your Gmail account, a window will be prompted to a welcome screen. Move ahead and click on the ‘Start measuring’ button.

After that, then you will be asked to enter the account name. This name is used internally to use your name as your business name.

Multiple account data sharing settings by Google Analytics. You can keep the default settings and move on to the next step.

Analytic Account

Step 3: On the next screen, you will be asked to create a Google Analytics property.

Google introduced a new version of Analytics called Google Analytics 4 or GA4. It’s the latest version that helps in creating your website and mobile apps in the same account.

Begin by entering a property name, choose your reporting time zone, and currency. Then, click the ‘Next’ button.

On the next screen, you will be asked to choose an ‘Industry category’ from the dropdown menu for the website and select a ‘Business size’ from the given options

Analytics-Business-detail

Next, scroll down and choose how you want to use Google Analytics with your business, like measure engagement, optimize advertising cost, increase conversions, and more.

multiple options or all of the given options can be selected according to your needs. Click the ‘Create’ button.

Create Google Analytics

Click on the create button, and a popup window will appear with Google Analytics terms of service agreement.

Click the checkbox for ‘I also accept the Data Processing Terms as required by GDPR’ and then click the ‘I Accept’ button.

analytics-accept

Click on the create button, and a popup window will appear with Google Analytics terms of service agreement.

Click the checkbox for ‘I also accept the Data Processing Terms as required by GDPR’ and then click the ‘I Accept’ button.

my-email-communication

Step 4: Now, Google Analytics Webs stream options will be displayed. Select the ‘Web’ as the platform

Analytics-web

Enter your website URL and Stream name. By default, Google Analytics has an Enhanced measurement option enabled. This enables you to track page views, scrolls, outbound clicks, file downloads, and more in Google Analytics.

Click on the ‘Create stream’ button.

The Stream URL, name, and Measurement ID can be seen.

It will display different enhanced measurements that it will record.

Google Analytics displays different ways to add Google Analytics code to the WordPress website under the ‘Tagging Instructions’ section.

By clicking on the ‘Global site tag (gtag.js) option, the Google Analytics tracking code can be seen.

Copy this tracking code as this will be needed to enter it in your WordPress site based on the method you use. Simply leave this browser tab open and switch back to copy the code when required.

After setting up a Google Analytics account, let’s see how to install Google Analytics in WordPress.

How to Install Google Analytics in WordPress

There are several methods to set up Google Analytics in WordPress. Below are three methods where the first option is the easiest and the last is the hardest.

Method 1) Google Analytics for WordPress by MonsterInsights

MonsterInsights is a famous Google Analytics plugin for WordPress. It is used by over 3 million websites, including the likes of Bloomberg, PlayStation, Zillow, WPBeginner, and more.

It is the easiest and best way to add Google Analytics to WordPress, it consists of the Dual Tracking feature that allows you to add Universal Analytics and Google Analytics 4 to your WordPress website without editing code.

Firstly, install and activate the MonsterInsights plugin. After activation, the plugin adds a new menu item labeled ‘Insights’ to your WordPress admin menu and a welcome screen is displayed. Click on the ‘Launch the Wizard’ button.

Launch setup wizard

launch-monsterinsights-wizard

Open the MonsterInsights setup wizard.

First, select a category for your website (a business website, blog, or online store). Choose one and then click on the ‘Save and Continue button.

setup-wizard

Next, connect MonsterInsights with your WordPress website.

Click on the ‘Connect MonsterInsights’ button.

You will be moved to Google accounts where you will need to sign in or choose a Google account if you are already signed in.

Select your Google account or enter your email to sign in.

sign-in monsterwizard

Next, you will be promoted to allow MonsterInsights to access your Google Analytics account.

Click on the ‘Allow’ button to continue.

 

MonsterInsights-Authentication-with-Google-Process

The next step is to select the profile you want to track.

Select your website here and click on the ‘Complete Connection’ button to continue.

The next step is to select the profile you want to track.

Select your website here and click on the ‘Complete Connection’ button to continue.

monsterinsights-settings

Using an affiliate link plugin will add the path that you are using to cloak affiliate links. This enables you to track your affiliate links in Google Analytics.

MonsterInsights will also ask who can see the reports. You can choose different WordPress user roles. Once you’re done, click on the ‘Save and Continue button to save your settings.

 

Next, MonsterInsights displays you a list of website tracking features you would like to enable.

Scroll down and click on the ‘Continue’ button or the ‘Skip for Now’ option.

On the next screen, MonsterInsights displays a message that you’ve successfully set up Google Analytics tracking.

Now, Google Analytics is connected, tracking code is installed, and data is now being collected.

connect-google-analytics-monsterinsights-success

Next, scroll down and see a field to enter your license key.

Click on the ‘Complete Setup without Upgrading’ option for now.

MonsterInsight-pro

You’ll need to create a Measure Protocol API Secret. This will enable MonsterInsights to track events like eCommerce purchases, form conversions, and more.

To start, log in to your Google Analytics account. Then, move to the admin settings page and click on the ‘Data Streams’ option

Choose the data stream you connected with MonsterInsights

Scroll down to the ‘Advanced Settings’ section.

Click on the ‘Measure Protocol API Secrets’ option.

A new window slide is seen in your Measurement Protocol API Secrets. Initially, this page is empty, and you won’t have any API secrets.

Click the ‘Create’ button.

Next, you’ll need to enter a nickname for your API secret.

Once you’ve done that, simply click the ‘Create’ button.

Your API secret will now be created.

Copy the API secret that’s under the ‘Secret Value’ field.

Next, you’ll need to enter the Secret Value in MonsterInsights.

You can do that by going to Insights » Settings from your WordPress admin panel and then clicking the ‘General’ tab.

monsterinsight settings

Move to the ‘Google Authentication’ section.

Enter the Secret Value under the ‘Measurement Protocol API Secret’ field

Measurement protocol API

The Measurement Protocol API Secret has been set up.

How to Set Up Dual Tracking When Using Universal Analytics

In case, if you already have a Universal Analytics account, then MonsterInsights makes it easy to track both Universal Analytics and Google Analytics 4 through its Dual Tracking feature. You do not need to edit any code.

To set up dual tracking, you can begin by moving to Insights » Settings from your WordPress dashboard and clicking on the ‘General’ tab.

monsterinsight settings

Scroll down to the ‘Google Authentication’ section.

Under the ‘Dual Tracking Profile’ field, enter the Univeral Analytics (UA) code.

You can find the Universal Analytics code in Google Analytics by going to the ‘Admin’ settings page.

MonsterInsight admin

Click on ‘Property Settings’ under the Property column.

The ‘Tracking Id’ is in the following format: UA-123456789-1.

Google analytic propery setting

The tracking Universal Analytics with Google Analytics 4 on your WordPress site can be tracked. Google Analytics takes some time before showing your stats.

The best feature about MonsterInsights is that it allows you to view your Google Analytics reports within your WordPress dashboard. Visit the Insights » Reports page to check out a quick overview of your analytics data.

Insight reports

It consists of Popular Posts addon that displays your top-performing content to boost your traffic and pageviews.

It can be used automatically to add inline popular post links to boost engagement.

Method 2) Insert Headers and Footers Plugin

This method is not as good as MonsterInsights as advanced tracking configuration cannot be used, and you will be unable to view Google Analytics data in your WordPress dashboard.

First, make a copy of your Google Analytics tracking code (Global site tag) that was copied in Step 4 earlier while creating a Google Analytics account.

MonsterInsight Tagging Instruction

Next, install and activate the Insert Headers and Footers plugin.

Once activated, visit the Settings » Insert Headers and Footers page. Paste the Google Analytics tracking code that you copied earlier into the ‘Scripts in headers’ section.

Google analytics header footer

Save the changes to store your settings.

Now, Google Analytics has been installed on your site.

Method 3) Install Google Analytics in WordPress Theme

This method is for advanced users who know the code. It is not reliable as your code disappears if you switch or update the theme.

First, copy the Google Analytics tracking code that was copied in Step 4 earlier. You can view it in the Webstream details section under the ‘Tagging Instructions’ section.

MonsterInsight Tagging Instruction

There are two ways to add this code to your WordPress theme files. You can choose either one of them

1) Add code in the header.php file

Edit the header.php file in the WordPress theme and paste the Google Analytics tracking that code you copied earlier right after thetag.

Save the changes and upload the file back to your server.

2) Add via Functions File

Add Google Analytics tracking code to the WordPress functions file. It will automatically add the tracking code to every page on your WordPress site.

Add this code to your theme’s functions.php file.

				
					<?php
add_action('wp_head', 'wpb_add_googleanalytics');
function wpb_add_googleanalytics() { ?>

				
			

Viewing Reports on Google Analytics Website

Google Analytics shows data collected from your stats. This data can be viewed by visiting your Google Analytics dashboard.

See Reports in Universal Analytics

Viewing Report on Google analytics

The built-in Google Analytics reports can be seen in the left column. Each section is divided into different tabs and clicking on a tab will expand it to show more options.

Here’s what different reports in Universal Analytics tell you:

  • Real-time report will tell you a real-time view of your traffic.
  • Audience tab will show reports to understand your users.
  • Acquisition reports explore where your users came from.
  • Behavior reports described what your users do after they arrive on your site.
  • Conversion reports tell how well you’re doing in achieving goals 

See Reports in Google Analytics 4

See Reports in google alalytics 4

Google Analytics 4 reports are different from Universal Analytics reports. In the left column, there are dedicated Reports options. The reports are combined under 2 broad categories, which included Life Cycle and User.

One of the differences that can be seen in GA4 reports is that there’s no bounce rate metric. Other than that, you’ll see a new reporting interface, new metrics like engagement time, there are no goals in GA4, and more.

Here’s a breakdown of different reports in Google Analytics 4:

  • Realtime report is similar to Universal Analytics and displays active users on your site in real-time.
  • Acquisition report displays medium users use to search your websites, like organic, referral, email, and affiliate.
  • Engagement report displays conversions and events that take place on your site.
  • Monetization report brings combines all eCommerce data in one place along with new reports like In-app purchases and Publisher ads.

Retention report displays new vs returning visitors.

  • Demographics allows you to observe website traffic from top countries, cities, and more. It shows gender breakdown and interest reports.
  • Tech report displays which device, browser, operating system, app version, and screen size is used by the people to view your website.

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420