How To Add Google Analytics To GeneratePress Theme?

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).

In that case, you can download and install GeneratePress child theme and insert additional codes there. It will save your functions.php and style.css files at the time of the core theme update.

What is Google Analytics code & how to get it?

The Google Analytics tracking code is also known by the universal tracking code. It is a JavaScript snippet that collects and sends data to Analytics from a website.

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.

google analytics 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“.

generatepress elements

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.

google analytics code generatepress hook

In the Settings tab, select a hook called wp_head.

google analytics generatepress hook

In the Display Rules section, select Entire Site >> Hit Publish.

google analytics tracking code generatepress hook

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.

insert headers and footers

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.

google analytics reporting
  • 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.

google analytics generatepress

Affiliate Disclosure: Some of the above links may contain affiliate links. It means we may receive a commission for purchases made through these links at no extra cost to you… [View Full Version]

You May Like These Posts Too

Leave a Comment

Subscribe to Blog via Email

Recently Published Posts

980 views
Share via
Copy link
Powered by Social Snap