Adding Google Analytics to the site is essential as it will help you to take important decisions for your business.
Why you need Google Analytics? It allows you to track and understand your user behaviour and activity on your site.
3 Ways Through which you can add Google Analytics to WordPress:
- Using WordPress Plugin for Google Analytics
- They are directly Injecting the code to the theme.
- Adding Google Analytics into Google Tag Manager
We will be discussing all the ways how to do it, in a simple way.
Using WordPress Plugin for Google Analytics
- Go to the plugin section and search for GA Google Analytics By Jeff Starr.
- After Installing the Plugin go to the Plugin Setting.
- You have to enter the GA analytics ID in the Setting Page.
- You have successfully added Google Analytics to the website.
Directly Injecting the code to the theme
- Go to the Appearance then theme editor.
- From the left panel, you have to select the header.php file.
- Copy and paste this code just after <HEAD> tag
- Then Press the Update Button to Save the Theme.
Adding Google Analytics into Google Tag Manager
If you haven’t used Google Tag Manager, then you don’t have to worry about this.
1. I will be explaining to you all the steps. Go to the GoogleTagManager, then press to create an account.
2. Then Fill the Details, ie. Account Name, Country, site URL and Target Platform.
3. The next step is a bit complicated, but not that difficult. Just follow the steps with me.
4. Go to the Appearance > Theme Editor > Header.PHP, you have to copy the GTM code into the header file.
There are 2 sections, Section 1 you have to paste in HEAD (Highlighted with Pink Color), Section 2 you have pasted in BODY (Highlighted with Red Color
5. Press the update button to save the file.
You have completed all the steps. You can track user activity in Google Analytics in Real-Time Tab.