Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

WordPress 5.2 "Jaco" released with PHP Error Protection & Site Health Check Feature READ MORE

How to Add Google Analytics to Your WordPress Websites

Updated on September 21, 2018

9 Min Read
google analytics wordpress
Reading Time: 9 minutes

Tracking visitors according to their interest is the key for businesses to lay down effective marketing campaigns. This useful data enable the marketing team to analyze various trends of their customers and how can they improve to increase ROI.

Google Analytics is one of the most powerful tools to monitor and analyze a website traffic. It is also a very important marketing tool that allows you to measure the results of your real-time web marketing campaigns and to measure your conversion rate.

In addition, Google Analytics is completely free so you have no excuses! Once installed, Google Analytics WordPress will let you know in detail who visits your website and what users are doing when visiting your website (page views, time spent on pages, bounce rate, the origin of the traffic, etc.).

Setting up Google Analytics On WordPress

Benefits of Setting Up Google Analytics

In general, having a good statistical tool lets you know how visitors interact on your website. Google Analytics can track visitors based on which sources they came from, including search engines, ads, click pay networks, email marketing, or PDF links. Google Analytics offers you several advantages such as:

  • Know who visits your website
  • Know what visitors are doing on your website
  • Know when visitors visit your website
  • Know where visitors come from on your website
  • Know how visitors interact with your website content
  • Know Who Visits Your Website

This form of web analysis allows to know the geolocation of your visitors, what browsers they use and other information such as language, screen resolution, JavaScript and flash support, etc. These data are very useful and can help you in different ways such as when you set your theme or you decide to change visual aspects and the appearance of your website. Hence you can be careful that your website is compatible with the devices used by your visitors.

If the majority of users do not have flash support, you should avoid adding this type of item to your website. If your users are using all screen resolutions, you need to make sure your website design fits in, that means Google Analytics can tell you if your website needs to be responsive or not.

Know What Visitors Are Doing on Your Website

You can determine what users are doing on your website. How much time do they spend and what is the bounce rate on your website. By using this information from Google Analytics, you can reduce your bounce rate and increase the number of views of your web pages.

Know When Visitors Visit Your Website

Just by looking at the peak hours of visiting your website, you can decide when you need to publish content: advertisements, articles, or others. If the schedules of your visitors are not compatible with yours, you can thanks to Google Analytics program your publications.

Know Where Visitors Come From on Your Website

Google Analytics shows you where the visitor comes from: search engines, direct links, referral links from other websites. It shows you the percentage of visitors coming from each of these sources. It also gives you details on each of these categories. If it is the search engine category, then it shows you which one brings you the most visitors: Google, Yahoo. Bing, etc.

Furthermore, Google Search Console shows you the keywords most wanted by your visitors so that you can improve your SEO. The details of the referral websites show you which websites you need most to work with. If your main reference source is Twitter, then you need to have exclusive Twitter content to make your audience feel special.

Know How Visitors Interact With Your Website Content

Google Analytics shows you how users interact with your website content. It shows you the percentage of clicks by the user, the link on which there were the most clicks and other relevant information. By seeing what your users are interacting with, you can work on targeted content.

After knowing the above-mentioned benefits of Google Analytics, you can focus on the strategies that work for your website and eliminate the ones that do not work.

Add Google Analytics to WordPress

Google Analytics is very easy to install on a WordPress website, even if you have no technical skills. On one condition: follow the steps of the installation. In this tutorial, we explain step by step how to set up Google Analytics to WordPress website.

Step 1: Create a Google Analytics Account

There are two ways of setting up Google Analytics.  First, create a Google Analytics account since this is the purpose of the first part. In a second step: connect your Google Analytics account to WordPress website. This will be the subject of the second part.

To create a Google Analytics account, go to analytics.google.com  From there, two cases arise:

  1. Either you already have a Google Account: just fill in your Gmail address and password. If you use Gmail as your mailbox, you have a Google Account by definition.
  2. Either you do not have a Google account: you must create one by clicking on “Create account“. It takes a few seconds to enter your first & last name, email address, password and some information about you (date of birth, mobile number, location, etc.).

Once all the information has been entered, click on “Next step” button at the very bottom of the page.

You are invited to accept Google’s Terms of Service. Do it, you have no other choice. A welcome message appears, click on “I Agree” button.

Now go back to the Google Analytics homepage and click “Sign In” (top right of the screen, next to the “Create Account” button). Your Gmail address is displayed: enter your password and click “Continue“. Now click on “Sign up” button at the top-right side of the page.

You are invited to enter the information of your website: account name, website name, website URL, industry category, reporting time zone. After that, click on “Get Tracking ID” button.

Note: Remember to select “Website” at the top of the page.

Google then invites you to accept Google Analytics Terms of Service, click on “I Accept” button.

You will then come to the interface of your Google Analytics account. Specifically, you are directed to the “Tracking Code” page and displays your “Tracking ID” (in the form UA – XXXXXXXXX-X) and your tracking code.

You will need the tracking code to add Google Analytics to WordPress website.

<!-- Global site tag (gtag.js) - Google Analytics -->
 
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
 
<script>
 
  window.dataLayer = window.dataLayer || [];
 
  function gtag(){dataLayer.push(arguments);}
 
  gtag('js', new Date());
 
 gtag('config', 'UA-XXXXXXXXX-X');
 
</script>

Note: You can access to tracking code at any time from the Admin tab > Tracking Information > Tracking Code.

Step 2: Insert the WordPress Google Analytics Code

To install the Google Analytics tracking code on the WordPress website, you have three possible methods. We present all: going from the most complex to the simplest method.

Method 1: Copy/Paste the Tracking Code Into Your Website Code (in the “header.php” file)

This first method can be a bit scary at first, but it’s actually not that complicated. Go to your WordPress Dashboard > Appearance > Editor menu and click on “header.php” file in the right column to edit the header code.

All you need to set up Google Analytics to WordPress website is to copy the “Tracking Code” from Google Analytics and paste it into the header code. But beware, not anywhere: the Google Analytics tracking code must be pasted just before the </head> tag.

Method 2: Install a Google Analytics WordPress Plugin That Inserts the Tracking Code

The second method is the fastest and easiest. If your theme does not allow you to do the first manipulation, another option is possible. It is not much more complicated than the first — in truth. This is to install a WordPress Google Analytics plugin. Google Analytics plugins, there are hundreds and hundreds. The vast majority of them are free and the problem is that many of these plugins are unnecessarily complex and full of features that do not serve any purpose.

1. Google Analytics Dashboard for WP

We will install a simple, well-coded and powerful plugin known as GA Google Analytics. To install it, go to Dashboard > Plugins > Add New. Type “ga google analytics” in the plugins search engine. The plugin should normally be displayed first, at the top left.

Click on “Install Now” button and then “Activate” the plugin. Once the plugin is activated, you must configure it. Go to Dashboard > Settings > Google Analytics > Plugin Settings, copy and paste the “Tracking ID” you find on the “Google Analytics Tracking Code” page (see previous screenshots if you’ve already forgotten).

You must check “Universal Analytics / analytics.js” and “Include tracking code in page head (via wp_head)” box, which allows to set up Google Analytics to WordPress. After that, at the end of the page, click on “Save Changes” button.

2. MonsterInsights

Another google analytics WordPress plugin is Google Analytics for WordPress by  MonsterInsights. It is a freemium plugin and is widely used due to its easy-to-use interface.

Once the plugin is installed, activate it and navigate to its settings page to link it with your WordPress with Google Analytics account.

Click on ‘Authenticate with your Google account’ button and log into your google account. In case of multiple websites under one Analytics account, choose the website you wish to track with this plugin and save settings.

The plugin will take a few minutes to fetch tracking data and will display the live tracking right on your WordPress dashboard.

Since I just set up the fresh account it has no tracking data to be shown. Tracking settings can also be configured using the plugin settings option.

These settings include the way you like Google to track your website traffic. It has settings for Google Ads and to configure eCommerce related tracking. Not all the options are accessible in the free version. Options like Forms, WordPress Google AMP, Facebook Instant Articles and performance settings are only accessible in Pro version.

Method 3: Hosting WordPress Google Analytics Locally

Google Analytics can be hosted locally on your server for better performance as it reduces external HTTP requests. To integrate such functionality we will be using a lightweight WordPress Google Analytics plugin called Complete Analytics Optimization Suite developed by Daan van den Bergh.

To install the plugin, head over to WordPress dashboard, search for ‘CAOS’. Activate the plugin and navigate to its settings page.

Enter WordPress Google Analytics Code and select the location to place the tracking script. Other options are also available under Advanced Settings.

Note: This is not recommended by Google but doing so can help you in avoiding warnings like ‘leverage browser caching’.

Step 3: Make Sure Google Analytics Works Well

The last step is to check that Google Analytics is installed on the WordPress website and works well. The easiest way to test is to go to Google Analytics > Real-Time > Overview. Then open a page of WordPress website (your homepage for example). If Google Analytics is connected to your website, you should see a bar. If so, it means that your website data goes back well in Google Analytics.

Note: It may take a few minutes or hours before the data goes back to Google Analytics.

Wrapping Up!

That’s it! We have now successfully set up Google Analytics to WordPress. All we have to do is make good use of it. To go further in the configuration of Google Analytics, you can create different profiles (including an unfiltered profile) by playing on the filters, create objectives or even consider setting up events/tracking eCommerce, according to your needs.

These configurations of Google Analytics will not only allow you to analyze your traffic, but also the conversion of your traffic. Do not hesitate to ask us for advice in the comment section below if you have any questions on the subject. It would be our pleasure to help you.

Frequently Asked Questions

Q1. How to add Google Analytics WordPress?

In order to add Google Analytics WordPress, set up a Google Analytics account and paste the tracking code inside the header file of your website. Similarly, google analytics WordPress plugin can also be used.

Q2. How to add Google Analytics WordPress plugin?

Search for the desired plugin using ‘Add Plugin’ tab and install the plugin. Once the plugin is installed, activate it and navigate to its setting page in order to connect it with Google Analytics account.

Share your opinion in the comment section. COMMENT NOW

Mansoor Ahmed Khan

Passionate about technology, entrepreneurship, and marketing, Mansoor Ahmed Khan is in computing since he knows how to type on a keyboard. His daily life is rocked by his family, projects, and his screen. Probably in this order, he likes to be convinced at least.

Start Growing with Cloudways Today!

We never compromise on performance, security, and support.

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

THERE’S MORE TO READ.