Skip to Main Content

How to install Google Analytics on your WordPress blog

Divi: the easiest WordPress theme to use

Divi: The best WordPress theme of all time!

With over 901.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates. [Recommended]

Knowing how your visitors behave on your blog is very important to your success. The best way to find out about these is to use your site traffic statistics. Google Analytics, a service offered by Google, is available free of charge and allows you to receive this analytical data.

In this tutorial, I will show you how to install Google Analytics on WordPress.


Why Google Analytics is so important to your blog?

Google Analytics lets you keep track of:

Those who visit your blog

This element is quite decisive, as it answers the question of the geographical location of your audience, the different browsers used and other information as important as the screen resolution, compatibility with JavaScript, Flash language and much more. .

This data is extremely useful, and it can help you in several ways. When using a new theme, you can use mobile data to make sure that mobile device users have no hassle while browsing your blog. If your visitors are not using Flash technology, then you should avoid adding any to your blog.

What they do when they visit your blog

You can follow the navigation of each visitor on your blog, see the time spent by them and see the bounce rate (the percentage of visitors who leave your blog after a first visit). Using this information, you can decrease the bounce rate and increase the depth of the page views.

When they visit your blog

This information can determine the peak time of your site, and you can choose this time to publish articles or display great promotions. This is how you can plan your articles.

How did they go to access your blog

This section of the analysis shows you where your visitors are coming from (for example: search engines, direct links or from another site and in this case we speak of referrer).

This section also shows you the percentage of origin from each source. Google Analytics also gives you a breakdown of each source. And especially with regard to sources, you will be able to see which search engines bring you more visitors.

Easily create your website with Elementor

Elementor allows you to easily create any website design with a professional look. Stop paying expensive for what you can do yourself. [Free]

How They Interact With Your Blog's Content

Google Analytics show you how your users are interacting with your blog content. In particular, it shows you the percentage of people who clicked on a link. This will allow you to set up A / B tests to see the content that has more effect.

How to get a Google Analytics account

The first step: you must start by creating a Google account. to do this, I invite you to google registration page.

You will go to a login page with a login form. If you have a Gmail account, then you can log in directly, if not you must create an account and click again on the previous link.


Second step : Once you've signed in with your Google Account, you'll be taken to a screen like the one below. It is on this window that you can connect to Google Analytics With your Gmail account.


Step 3: On the next screen, you will have the choice between the website or the mobile application. Make sure that the option " website Is selected.

Currently Google offers universal access with a single account, which offers exceptional features and an analytics account. You are free to use it.


Carefully read the various information requested and fill them in. For example, you will fill in information such as website name, website address, reporting time zone, website category and more. Once it's done, click on " Get a tracking ID“, You will then access the Google Analytics embed code on your WordPress blog.

google-analytics code

How to install Google Analytics on WordPress

There are two methods of doing this. One with a plugin and the other by entering the tracking code in a file of your theme.

Using a plugin

Remember, I showed you how to create a plugin. All you have to do is add the following code.

google-analytics-integration code

Note: JavaScript code is provided by Google (Js Tracking Code), I simply copied it into my PHP function.

Do not forget to replace the mention "Your Code HERE" by the identifier of your Google Analytics account. The latter is often composed of " UA »And a series of numbers.

In addition, you can use the plugin ' Header and Footer »Available on

Paste the code into a theme file

This is a method I don't recommend, but you can still use it if you don't plan on changing the theme. All you have to do is open your theme's "header.php" file and directly paste the tracking Js code provided by Google.

Easily create your Online Store

Download free WooCommerce, the best e-commerce plugins to sell your physical and digital products on WordPress. [Recommended]

 Note: Google offers several methods of integrating Google Analytics, so the choice is yours.


That's all you need to do to install Google Analytics on your blog. Feel free to share the tutorial with your friends on your favorite social networks.

This article features 0 comments

Leave a comment

Your email address will not be published. Required fields are marked with *

This site uses Akismet to reduce unwanted. Learn more about how your comments data is used.

Back To Top