Google Analytics allows you to track your website traffic. It is a free service provided by Google. By creating an account and connecting it to your website, you can start to analyse traffic data in depth. However, in order to track this data, you need to insert a Google Analytics tracking code into your website...
Good news, the Divi theme allows you to do this easily and quickly without installing an additional plugin. Let's see how to do it...
- The usefulness of Google Analytics
- Why do you need to integrate a tracking code into your site?
- Create a Google Analytics account
- Get a Google Analytics tracking code
- Where to embed the tracking code in Divi
- Check that the tracking code works
Announcement: this article contains affiliate links that you will easily recognise. The classic links are in purple and sponsored links are in pink.
Getting started with Divi, discover all the articles to start with peace of mind!
1 - The usefulness of Google Analytics
Connecting your website to Google Analytics is not mandatory. However, Google provides us with a great tool that allows us to track the ROI (return on investment) of our website.
Why not? It would be a shame!
The analysis of the figures and statistics is rich in information. You will know which pages are the most visited, how many pages are visited by the same user, how much time is spent on the site and more!
Google Analytics data is very comprehensive and will allow you to better consider your future marketing actions.
2 - Why do you need to integrate a tracking code into your site?
The reason is simple, for security reasons, Google wants to make sure that you are the owner of the site whose data you want to track.
To prove that this is the case, you must have access to the administration part of your site.
By inserting this code, Google will be able to read it. This validates your property and allows Google to start recording visits.
It's a good thing that Google verifies that you are the owner of the site, otherwise anyone could track the statistics of any site!
3 - Create a Google Analytics account
If you don't have a Google Analytics account yet, you can quickly create one at At the following address.

- Click on "Get started for free".
- You will be redirected to sign in to your "Google Account". If you don't have one, you can create one at this stage.
- Click on "Register".
4 - Get your Google Analytics tracking code

- Choose "Web Site" section
- Give your account a name
- Give your site a name. For example "My site.
- Enter the URL of your site, and do not forget to choose the option http:// or https://
- Define the sectoral theme of your site among the proposals,
- Choose the time zone according to the country
- Click on Click on "Get a Tracking ID".
- Accept the terms and conditions of use.
You will then be directed to the page dedicated to your property.

All you have to do is copy the Google Analytics tracking code in the dedicated field. Be careful not to forget to copy the whole code.
The Google Analytics tracking code looks like the one below:
< ! -- 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-XXXXXXXX-X’);
< / script >
Did you know that you can test Divi for free? Go to this page and click on "TRY IT FOR FREE
5 - Where to integrate the tracking code in Divi
Once you have copied the code from the previous step, go to your site's administration, to the : Divi > Theme options > Integration
Read this article to understand all the settings in the Divi Integration tab.

- Check that all buttons are activated
- The first window corresponds to the HEAD section of your site
- The second window is the BODY section
It is in one of the two fields that you can paste your Google Analytics tracking code. Google recommends pasting it in the HEAD section (tab 2), while Divi suggests pasting it in the BODY section (tab 3). Both work: choose one of the two. Remember to save your changes before leaving.
6 - Check that the tracking code works

To be sure that the Google Analytics tracking code has been taken into account, I advise you to browse your site as an average Internet user would and to view the figures in your Google Analytics account at the same time. You should see real time views: yours (at least).
Need more resources on Divi? Visit the ElegantThemes blog which is full of ideas and tutorials!


Merci, c’est très clair !
Merci à toi Maité 😉
Bonjour,
Je découvre Divi et inévitablement je suis à la recherche de divers trucs et astuces pour mettre en route un nouveau site.
Curieusement je me retrouve souvent sur « Astuces-Divi »
Merci pour le boulot.
Merci Patrick 😉
Merci !! super bien rédigé !
Merci pour cet article !
Salut Lycia.
Article toujours très intéressant comme toujours!
Mais désormais on n’a plus la partie Code de suivi dans Analytics, plus de gtag.js…
MErci !
Salut Pat ! Oui en effet je vais mettre l’article à jour
Pas de soucis merci pour tes tutos toujours précieux !