How to Connect Google Analytics to WordPress Without Using a Plugin

Right after setting up your WordPress website, setting up Google Analytics should be right there at the top of your list when it comes to “What to do next?”.

It is important to have it integrated to your WordPress website so that you can collect useful information about your audiences such as their location, their age group, their browsing behavior in your website and much more critical data which helps you understand your audience better.

The best part about it is that you can use the information collected as an aid to grow your website.

But when it comes to the question of how to connect Google Analytics to WordPress, you should know that there are a few ways to do it.

One of the ways is by pasting the Google Analytics website tracking code into your WordPress theme’s Theme Header file. I will show you how to do this.

First things first, you will need to copy the Google Analytics website tracking code from your Google Analytics account.

The code can be found under Tracking Info > Tracking Code.

Once you have copied the website tracking code, head over to your WordPress website’s dashboard.

In the dashboard, head over to the Theme Editor.

Next, locate the Theme Header file or also known as header.php and click on it.

Now, this is where the not so easy part comes in.

You will need to paste the Google Analytics website tracking code you copied earlier right before the closing </head> tag. Here’s an example:

Once the above is done, update the file.

That’s it! You have successfully integrated Google Analytics to your WordPress website.

On the other hand, whenever you change your WordPress theme, you should always remember to re-paste the website tracking code to the new theme’s Theme Header file. This is because as you change your WordPress theme, all the theme files will also be changed and the previous website tracking code will be gone with the wind.

In other words, if you don’t remember to re-paste the website tracking code after changing the WordPress theme, Google Analytics will not be able to connect to your website. Hence, not being able to track, collect and report audience data.

Alternatively, you can use a plugin to integrate Google Analytics to your WordPress website. Using a plugin will avoid the necessity to re-paste the tracking code whenever you change your WordPress theme. See my tutorial here – How to integrate Google Analytics with WordPress using a plugin