“Every time I update GeneratePress theme, I lose Google Analytics code from the theme. What should I do?“
This was the earliest question asked by Mr Amit, in GeneratePress free vs premium post’s comments box.
In the beginning day, I had faced this problem too. And I think there are so many newbies also, looking for a permanent solution too.
So, in this tutorial, I will teach you how to add Google Analytics code to GeneratePress theme free and premium version.
In fact, I have added a YouTube tutorial to make your work easier easy for adding universal tracking code to track blog traffic and user experience statistics.
So, without wasting time, let’s get started with GA introduction.
Why you lose tracking code every time update GeneratePress theme?
WordPress is an open-source system. Whenever an update comes, the system, replaces the old files with the new version.
In results, all your added CSS PHP automatically deletes from the theme (this also happens to WordPress plugins too).
What is Google Analytics code & how to get it?
By installing Google Analytics on your site, you can track all data on every page of your website e.g. page views, user experience, bounce rates, dimensions, metrics etc.
Get GA setup universal tracking code
Visit analytics.google.com and login with your Google Account.
Then click on Admin >> Property >> Tracking Info >> Tracking Code.
Copy this code and save into notepad.
How to add Google Analytics to GeneratePress theme?
Pacing GA code in GeneratePress is simple but different methods for free and premium version theme users. So I have divided this guide into two sections.
- Setup Google Analytics code in GeneratePress Pro (GP Premium)
If you have already installed and activated GP Premium plugin on your WordPress site. Then follow the below steps:
Login to your WordPress Admin Area then tap on Appearance >> Elements >> Add New and choose “Element Type” “Hook“.
Next, add hook title (this wouldn’t show in blog posts) and in the editor box, copy and paste the universal tracking code, you copied earlier.
In the Settings tab, select a hook called wp_head.
In the Display Rules section, select Entire Site >> Hit Publish.
That’s it. Google Analytics Code setup has been completed. Google will start tracking your website reports.
- Insert universal tracking code in GeneratePress theme (free version)
If you are using GeneratePress free version then there is no direct option to place Google Analytics Tracking Code. And if you add in the header.php folder, it will be deleted automatically at the time of theme update.
To get rid of this issue, download, install and activate a plugin name Insert Headers and Footers.
Next, open the Plugin Settings >> paste the Google Analytics code in, “Scripts in Headers” and then click on Save Changes.
That’s all, you have successfully installed Google Analytics on your site.
Viewing reports on Google Analytics website
With the help of GA setup, you are capable to measure your website stats and traffic reports. Take a look at GPressTheme blog analytics statistics.
- Real-time section shows you the real-time (live) traffic on the site.
- Audience tab reports help you understand your user’s experience.
- Acquisition reports explore where your users came from.
- Behaviour reports summarize what activities your visitors do after they arrive on your site.
- Conversion reports give you stats and conversion rate details against your goals.
Final words on Google Analytics setup
No doubt Google Analytics tracking code is one important factor to keep an eye on your website activities with users.
I hope this article helped you learn how to add Google Analytics code to GeneratePress theme free and premium version.
Still found something missing? Please don’t hesitate to send me a message via the comments box below. I will be happy to help you out.