How to Add Google Analytics To GeneratePress

How to Add Google Analytics To GeneratePress

In this post I will show you how to add Google Analytics to GeneratePress theme. Without using any WordPress plugin, you can easily add the Google Analytics tracking code to GeneratePress.

If you have used some third-party WordPress themes, you may have found a built-in option to add the Google Analytics code. Most of the themes provide an option to enter the Google Analytics tracking code. However, with GeneratePress theme, you can either use plugins to add Google Analytics tracking code or add it manually.

GeneratePress is a free WordPress theme which is responsive, light weight, customizable and well coded. If you buy the premium plugin (also known as GP Premium), you get access to all the modules which adds lots of features and functions.

Install and Update Third Party Applications with Patch My PC
Install and Update Third Party Applications with Patch My PC

I am not going to cover about plugins that can add Google Analytics To GeneratePress theme because adding plugins may affect site loading speed. Moreover, if the plugin developer doesn’t provide any updates, you may encounter issues with plugin later.

What is Google Analytics Tracking Code?

So, what exactly is Google Analytics tracking code? – The Google Analytics tracking code is a snippet of JavaScript that collects and sends data to Analytics from a website. When you add the Google Analytics tracking code to your GeneratePress, you can analyze in detail how users behave on your site.

Ways to Add Google Analytics Tracking Code

There are two ways to add the Analytics tracking code to your GeneratePress theme.

  • Add the tracking code to the HTML of each page on your site.
  • Use a tag management system such as Google Tag Manager.

In my opinion, adding the code to HTML of each page seems to be much easier than using Google Tag Manager. Moreover, you don’t need any plugin here because GeneratePress makes it very easier to add Google Analytics tracking code.

Google Tag Manager has its advantages but consider the following points before using GTM.

  • You use multiple analytics and ad performance tracking tools that require site tags.
  • Adding tags to your website slows down your ability to run marketing campaigns.

Where can I find Google Analytics Code and Tracking ID?

Use the following steps to find your Google Analytics code and Tracking ID.

  • First sign in to your Google Analytics account.
  • Click Admin and select a property from the menu in the Property column.
  • Under Property, click Tracking Info > Tracking Code.
  • Copy this code, and we will add it to GeneratePress theme.
Find Google Analytics Code and Tracking ID
Find Google Analytics Code and Tracking ID

How to Add Google Analytics To GeneratePress

To add Google Analytics Tracking code to GeneratePress theme.

  • On the WordPress dashboard, click Appearance > Elements.
  • On the Elements section, Click Add New Element.
Add Google Analytics To GeneratePress
Add Google Analytics To GeneratePress
  • You must select an element type here. Select Hook and click Create.
Add Google Analytics To GeneratePress
Add Google Analytics To GeneratePress

Type the name of the hook. I have specified the name as Google Analytics Tracking Code. Paste the Google Analytics Tracking code from the analytics portal in the text box.

Select the Hook location as wp_head. The common question that many of us have is should I place the Google Analytics code in header or footer. It’s the header because by placing the tracking code in your header, you’ll be more likely to get the accurate stats.

Add Google Analytics To GeneratePress
Add Google Analytics To GeneratePress

Click Display Rules and select the Location as Entire Site. Click Publish.

Add Google Analytics To GeneratePress
Add Google Analytics To GeneratePress

You have successfully added the Google Analytics To GeneratePress theme. If you are using caching plugins, do not forget to clear the cache. Visit Google Analytics portal, and you can now view the total users who are actively browsing your site.

Need more help?

If you need further assistance on the above article or want to discuss other technical issues, check out some of these options.