Add Google Analytics to WordPress.

4 Easy Ways to Add Google Analytics to WordPress

Share on social media

Share on facebook
Share on linkedin
Share on twitter
Share on email

Many users WordPress are having difficulty connecting Google Analytics to their site. This is necessary to collect data about its visitors.

There are several ways to add Google Analytics to WordPress. Once you get the hang of them, these techniques are pretty simple and useful in a variety of situations.

In this post, we will discuss what does Google Analytics and why it matters to your site. We'll then go over 4 ways to connect it to WordPress to start tracking activity.






A quick introduction to Google Analytics.

Before you start connecting Google Analytics to your WordPress site, it's important to understand what it is and how it works.

This platform tracks the activity on your website and provides you with key data to help you improve it.

google analytics for wordpress

Image: Google Analytics home page.

By using a snippet of code inserted into the header of every page on your website, Google Analytics collects a wide range of information. It can be divided into five categories:

  • Real-time events: what is happening on your site when you view the report.
  • Audience: Information about who is visiting your site, including demographic information.
  • Arrival: traffic sources.
  • Behavior: The actions of your site visitors, including button clicks and which of your pages are most popular.
  • Conversions: An advanced report that will be used in conjunction with Google Analytics goals. It can help you track activities such as email subscriptions or e-commerce sales.

Here are some examples of specific information you can find in your Google Analytics reports:

  • The number of active users on your site at any given time.
  • How many people visit your site over a period of time.
  • The age, gender, and location of your visitors.
  • Where your visitors come from: organic search results, social media, etc.
  • Which pages visitors are viewing and for how long.
  • Bounce rates, clicks and conversions.

The Google Analytics dashboard provides many tools for collecting information about site activity. It can help you improve your web resource in many ways.

Why analytics is important for your WordPress site.

If you know how to use analytics effectively, it can be useful for all kinds of sites. There are four key areas:

  • Content marketing strategy. You can determine what your visitors like the most on your web pages. Increasing page views and traffic requires creating the type of content that best suits your audience.
  • Inbound marketing. Traffic sources to your site show you which marketing strategies work and which don't. This will help you focus the bulk of your effort and budget on the methods that get the most out of your business.
  • Audience segmentation. Understanding your audience is key to effectively communicating with them to encourage conversions. With analytics, you can create subgroups for targeted marketing.
  • UX user experience audit. User behavior streams can reveal problems with your navigation or site design. Identifying underperforming content and high bounce rate pages can help you improve problem areas.

If you have an e-commerce site, the conversion report is also useful for tracking sales and revenue.

How you apply the knowledge you gain from Google Analytics is where the value comes in. Troubleshooting and applying the best marketing techniques for your website can lead to increased traffic, conversions, and revenue.

Google Analytics is the standard when it comes to web analytics tools. Check out this guide to learn how to connect GA to WordPress.

How to Add Google Analytics to WordPress: 4 Ways.

If you're trying to collect data about your users, here are some ways to connect Google Analytics to your WordPress site.

In each case, we will assume that you already have a Google Analytics account set up. If it doesn't already exist, create it. Then you can use these 4 ways:

  1. Add Google Analytics to WordPress using a plugin.
  2. Connect Google Analytics and WordPress with a manual code.
  3. Integrate Google Analytics and WordPress with Google Tag Manager.
  4. Sync Google Analytics locally for Performance Reasons.

1. Add Google Analytics to WordPress using a plugin.

For most WordPress users, the easiest way to add Google Analytics to their sites is with a plugin. This method saves you the hassle of editing your site's code.

We recommend two plugins for this:

Site Kit from Google.

If you want to add Google Analytics to your WordPress site, Google provides you with a simple yet powerful plugin: Google's Site Kit.

Site Kit with Google WordPress plugin

This free plugin connects Google Analytics to your WordPress site in just a few clicks, but that's not all. In addition to analytics, this plugin extracts data from other services provided by Google such as Google Search Console, Google AdSense and PageSpeed Insights. This allows you to create a beautiful Google-based dashboard as your data source.

Here's how to get started:

Install and activate the Google Site Kit plugin, then click the "Start setup" button.

Google Site Kit plugin

When you're done, you will need to connect your WordPress site to your Google Analytics account.

You will need to follow a few steps to make sure you own the domain, give Google access to its data, and configure each service you want to add to WordPress.

Google Site Kit configured successfully

After successfully connecting to your Google account, you will be able to view data from Google Analytics along with all other services activated directly from your WordPress dashboard. This is how it looks:

Google Site Kit dashboard

All of this data will always be available in WordPress on the left sidebar.

If this plugin is too important for you and you want to focus primarily on Google Analytics, you can use the following plugin.

GA Google Analytics.

The free GA Google Analytics plugin by Jeff Starr has over 400,000 active installs and a five-star rating:

google analytics logo

After installing and activating the plugin, all you need to do is add your Google Analytics Tracking ID in its settings. To get your tracking ID, go to your Google Analytics account and click Admin in the sidebar:

tab admin google analytics

Under Properties, select Tracking Information, then click Tracking Code:

access to the google analytics tracking code in the property information section

Your Tracking ID will start with UA and will be at the top of this section:

access to google analytics tracking id

On your WordPress dashboard, go to Settings> Google Analytics. Scroll down to plugin settings and add your tracking code in the appropriate field:

ga the settings page of the wordpress plugin for google analytics

This plugin also lets you choose if you want the tracking code to be placed in your header rather than the footer. You can also add custom tracking code, enforce SSL, disable tracking for admin users, and some other useful options.

Once you've configured your needs, scroll down and click the Save Changes button. Google Analytics should now be active on your WordPress site.

2. Connect Google Analytics and WordPress using the code manually.

If you don't want to use the plugin, it's also quite easy to add the Google Analytics tracking code directly to your WordPress theme via your functions.php file.

If you are going the manual route, it is important to use a child theme so that your tracking code is not overwritten every time you update your WordPress theme.

It is recommended that you create a backup before making any changes.

Once your child theme is active, you need to insert your Google Analytics tracking code right before the closing tag in the header.php file.

To find the Google Analytics tracking code, go to your account and access the tracking information as we described in the previous method. Then you can copy the script out of the box under the Google Site tag:

copying the google site tag code

To add it to your WordPress site, choose Appearance> Theme Editor. If your child theme inherits template files from its parent, you won't see header.php here. You can click on the name of your parent theme in the file list to access it:

wordpress theme editor for kids theme

Once you find and select header.php, paste the Google Analytics tracking code right before the tag in the editor:

editing header php file in wordpress

Then be sure to click the "Update File" button. Google Analytics tracking code is now being added to WordPress.

3. Integrate Google Analytics and WordPress with Google Tag Manager.

Another method that you can use to add Google Analytics to WordPress is using the Google Tag Manager. It is intended for sites that include scripts for various purposes, not just analytics.

Google Tag Manager is a tag management system. It allows you to quickly and easily update tags and code snippets on your website or mobile app.

You can add and update scripts from the Tag Manager UI instead of editing the site code in WordPress. This reduces errors and frees you from having to involve a developer when setting up your tags.

The easiest way to do this is to use the free Google Tag Manager WordPress plugin. It currently has over 300,000 active installs and a five-star rating.

google tag manager for wordpress plugin

You can download the Google Tag Manager plugin from the WordPress repository or find it under Plugins> Add New in your WordPress dashboard. Next, you will need to register for a Google Tag Manager account and create your first container.

After following the steps above, you can copy your container ID from your Google Tag Manager dashboard by going to the Admin tab and searching for a series of characters starting with GTM:

search for container id in google tag manager

Then go back to your WordPress site and paste the Google Tag Manager ID into the appropriate field on the plugin settings page. You can get there by going to Settings> Google Tag Manager:

adding container id to google container plugin tag manager

Any tag that you have set in Google Tag Manager, including the tag for Google Analytics, will now work on your WordPress site via a plugin.

4. Synchronize Google Analytics locally for Performance Reasons.

The last method you can use is to sync the Google Analytics script locally to your own server.

Please be aware that this method is not supported by Google!

However, there are several reasons why you might want to do this. First, Google Analytics local syncing can cut your external HTTP requests. In addition, you will have full control over file caching so that you can use your own server's cache headers.

This is essential to improve the performance of your site. If you are using Google PageSpeed Insights, you may see a "Serve static resources with effective caching policy" warning for your Google Analytics script:

example google analytics alert

The problem is that Google Analytics has a 2 hour cache time by default, as you can see in the alert above. If Google needs to change something from the start, it wants all users to have access to the changes as quickly as possible.

By hosting the Google Analytics script on your own server, you can change the caching times to improve performance.

Google Analytics local sync with full suite of Google Analytics optimization tools.

To get started, we recommend using the Complete Analytics Optimization Suite CAOS. This is a free plugin created and developed by Daan van den Bergh. It currently has over 20,000 active installations with a five-star rating.

caos host google analytics local plugin

You can download it from the WordPress repository or search under Plugins> Add New in your WordPress dashboard.

CAOS allows you to host your Google Analytics JavaScript file, analytics.js locally and update it using wp_cron (). Other features allow you to:

  • Anonymize the IP address of your visitors.
  • Set an adjusted bounce rate.
  • Change the Google Analytics script location, header or footer.

Important: you will need to deactivate any analytics plugin you have already installed before using CAOS.

When you install CAOS and enter your Google Analytics Tracking ID, the plugin adds the required Google Analytics code to your WordPress site.

It then downloads and saves the analytics.js file to your server and updates it with a scheduled script in wp_cron ().

We recommend setting up the script to load into the footer by going to Settings> Optimize Analytics and selecting the Footer option under Tracking Code Position:

settings for local sync google analytics

It is important to note that CAOS does not work with other Google Analytics plugins.

Synchronization of Google Analytics locally with Perfmatters.

Another plugin that you can use for local analytics is Perfmatters. This is a premium website performance optimization plugin created by Brian Jackson and his brother Brett:

perfmatters wordpress plugin

Among the many features, there is also the option to sync Google Analytics locally by entering your tracking ID. Like CAOS, you can also set the script to load in the footer instead of the header.

Output.

Google Analytics is an essential tool for website owners and managers. Keeping track of your site's user activity, referral sources, and other data is key to growing your audience.

You can connect Google Analytics to your WordPress site in the following ways:

  1. Add Google Analytics to WordPress using the Site Kit plugin or GA Google Analytics.
  2. Connect Google Analytics and WordPress manually by adding code directly to your theme.
  3. Integrate Google Analytics and WordPress with Google Tag Manager.
  4. Sync Google Analytics locally for performance reasons using CAOS plugins or Perfmatters.

Are there any thoughts or other methods you are using to add Google Analytics to WordPress? If so, we'd love to hear from them!

Based on materials from the site: kinsta.com.

✓ What is GA Google Analytics?

GA stands for Google Analytics. This is a program for collecting data about the activity on the site.

✓ Use Site Kit from Google or GA Google Analytics?

It depends on personal preference. Learn more about each product and test it.

✓ What is a script?

It is a scenario: a specific sequence of actions for a program to complete a task.

✓ What is Google's Site Kit for?

It is a tool for collecting and analyzing user behavior on the site.

✓ How to add Google Analytics to WordPress?

One of the options.
In the control panel WordPress you need to install the plugin Analytics Code Integration. Then, in the Settings section, click Google Analytics Code... After that insert the identifier Google Analytics and click Save.

✓ How to install traffic counter on WordPress?

First, you need to register the site in order to get the counter. After that, you need to choose the type and design of the meter itself.

✓ How to use Google Analytics?

Google Analytics allows you to view statistics from sites and applications for mobile devices, sales accounting systems. Also, the service can be used to work with clients and various Internet platforms. Google Analytics saves relevant information in the form of reports.

Share on social media

Share on facebook
Share on linkedin
Share on twitter
Share on email
5/5

Leave a Comment

Subscribe Now

Exclusive offers and premium cases

how to create an ico listing website
All Cases

How to create an ICO LISTING website?

Blockchain is becoming extremely popular. First of all, thanks to cryptocurrencies. But before cryptocurrency comes into play, a few things happen. One of them is ICO. The number of ICOs is growing rapidly, and, of course, only a few of them really deserve attention. We are going to explore the following questions:

how to create a successful ICO website
All Cases

How to create a successful ICO website?

While you should hire professionals to help you build your site, you can still do the preparation and planning a lot. This will simplify the design process and save money. Start by creating all the relevant content your site needs.

Looking to take your business to the next level?

Email us now

Conversion Growth

REQUEST

Back call

Write to us