Most WordPress users have difficulties to connect the Google Analytics code to the site. Luckily, there are endless ways to embed the Google Analytics code in WordPress.

What does Google Analytics do? Why is it so important for the WordPress site? What are the methods to connect it? Track the activity of the site is important to know what users want.

Insert Google Analytics WordPress code is a step that sooner or later you will have to do in the blog, in the showcase site and above all in an e-commerce. Why?

In fact, with the data you can monitor anything, such as, for example, the frequency of turnover, the pages visited, the type of devices, the time spent, the type of content most visited, and then, your favorites.

Never underestimate the objectives and analysis tools that allow you to insert precise metrics that relate to the needs of the project. To give a concrete example of this concept, we mention the landing pages.

To understand how users arrive there, where do they click, what do they do etc., you must enter the Google Analytics code on WordPress. How to do it? Through a plugin? Manually? There are many methods and we will deepen them in every part. 

The guide helps to have a visit report based on real Google numbers. We will teach you how to insert the code and how to connect Google Analytics to the WordPress site in a few clicks. What allows you to have Google Analytics on WordPress? 

Google Analytics is certainly one of the main tools to install on your WordPress site to understand who is visiting the site, where it comes from, and at which pages it is interested.

Inside the guide you will find what is the Google Analytics code, what is it for, how to connect it to WordPress, where to insert it precisely with the relative steps. To finish with how to do it manually and how to do it via a plugin. I wish you a good reading continuation!

What is the Google Analytics code?

Let's start with a quick introduction to this website linkable tool. The platform monitors the activity of the site and offers data to improve it.

With the code fragment that is inserted precisely in the header of the page, it collects useful information for the user, divided into 5 areas: real-time, public, acquisition, behavior and conversions. 

Some specific information includes numbers of: active users, people who visited the site, age, gender, location, devices, bounce, conversion rates etc.

The definition of Google Analytics is provided by Wikipedia in the most appropriate way:

Google Analytics is a free web analytics service provided by Google that allows you to analyze detailed statistics on visitors to a website. The service is used for internet marketing and by webmasters. Google Analytics is the most used on the web, with a market share of 85.4% in the top 10 million sites (according to Alexa). Google Analytics is used by about 56.4% of the same websites.

What is the Google Analytics WordPress code for?

The Google Analytics WordPress code is used to monitor user information and improve the strategy. Some key elements are absolutely relevant to every site. The strategy is one of these. 

Follows the seo optimization, the UX user experience, the target etc. In the case of a e-commerce site, Google Analytics reports the rates conversion based on specific metrics. When it comes to web analytics tools, Google Analytics is the first to play. 

Without it, no user will reach your site. The free tool granted by Google, that is Analytics, allows website users to monitor everything that happens to users who enter and navigate the site in every particular detail and path. 

It looks like a tool that shows precise statistics and data relating to accesses, visits, movements, conversions and so on.

How to connect Google Analytics to WordPress?

To connect Google Analytics to WordPress we see several effective methods that start from programming languages ​​up to plugins. Mainly, there are two main methods: manually or via plugins.

To collect user data in the best possible way, you need to link the Google Analytics code on WordPress. You certainly start by creating the account on Google Analytics and then adding the code. Another way to do it is Google Tag Manager.

In this guide, we will focus on the 2 most important existing ways. We will see the steps to connect it manually. We will find out where to precisely insert the code provided by Google after having made the account and having paid the domain of the site. Then, let's finish with how to do it with a plugin.

Where to insert Google Analytics WordPress code: the steps to link it manually

First we need to retrieve the code to activate your account on Google Analytics & the steps required to get the code.

Once you have created the account and entered the name of the site to connect it, click on the section referring to the administration and in the column called Ownership, click on Monitoring information and then on Tracking code.

In this window there will be the code and the ID. Copy and save everything in a text file. Now that you have the code on hand, you can insert it in WordPress. Let's see how to do it manually without too many problems. This can be done easily via the website theme settings.

Templates offer precise text areas on the configuration page. In this section you can put the code by making a simple copy and paste in the theme header and finally save. At this point the code has been automatically added to all pages of the site. 

Let's summarize the precise steps :

  • log into analytics
  • select admin tab
  • click an account from the menu
  • verify ownership
  • click on tracking information
  • copy code
  • go to the WordPress dashboard via login

Once you are on the wordpress cms, follow these simple steps:

  • go to appearance
  • then on editor
  • php file on the right (theme header)
  • Open and paste the code before closing the tag
  • Save

Support.google.com delves into an important aspect:

The Tracking ID is displayed at the top of the page.

The global site tag is displayed at the bottom of the page in a text box under Website Monitoring - Global Site Tag (gtag.js)

The global site tag is composed of several lines of code that you have to paste into each web page to measure.

At this point the Google guide tells us to add this tag on the pages of the site. How? Just copy the content shown and paste it exactly after the opening tag on each page of the site you need to measure. Logically, we recommend inserting it on every page.

You can manually insert the code in another simple way. Go to appearance, in the drop-down on the left of the WordPress control panel, then to editor and finally to template.

Connect Google Analytics to WordPress with Google Site Kit plugin

Are you looking for a better and simple method to link the Google Analytics code on WordPress? You can do this with a plugin called Site Kit directly provided by Google. In this way we will avoid modifying the code and will do the whole plugin.

It is a very powerful extension, which in a few clicks inserts the code on WordPress. Once the plugin is installed and activated, click on Start. It will open a window that communicates the request to connect the WordPress site to the Google Analytics account.

Follow the required steps (verify owner) and at the end of the procedure the connection will occur with success. Easy, fast and convenient.

Read also: How to use Google Trends to Grow Your Website's SEO