How to Add Google Analytics in GeneratePress

Last updated:

Please note that I may earn a small commission from purchases made through product links in this article at no extra cost to you. I only recommend products that I have personally used and tested.

 

If you’ve read my review of GeneratePress, then you know I’m a big fan of this theme. It’s fast, it’s super customizable, and most importantly, it’s as robust as it gets.

One question I get asked quite a lot is how to actually add the Google Analytics tracking code in GeneratePress.

The good news is that there’s no need to install another plugin for this task, and there’s also no need to edit any WordPress files. In fact, the process within GeneratePress is actually quite easy. You just need to know how to do it.

So let’s get straight into it.

Try GeneratePress

Adding Google Analytics in GeneratePress

The following steps assume you already have collected your Google Analytics tracking code, and you’ve got that ready to add to your GeneratePress powered blog.

Also note that you can use the exact same steps below to add the site-wide Google AdSense code.

1: Create a Hook Element

The first step is to create a new Hook Element. Navigate to Appearance, Elements, then Add New. Select Hook from the dropdownlist.

Create new Hook Element in GeneratePress

In the screen that follows, you can edit the new Hook element.

2: Add Your Google Analytics Code

In the editor box, copy and paste your Google Analytics tracking code:

Paste Google Analytics tracking code in Hook editor

Make sure you give this new Hook Element an appropriate name, such as “Google Analytics”. I know, it’s not very original, but you get the point.

3: Configure the Hook Settings

The next step is to configure the Hook element such that the Google Analytics tracking code will be added to the HMTL head element of all pages in your website.

In the dropdownlist located next to Hook, select wp_head. This adds the tracking code to the head element of your HTML output, which is where you want it to be.

Configure the Hook settings

In the Display Rules tab, next to Location, select Entire Site from the dropdownlist. This will, you guessed it, add the tracking to all pages of your GeneratePress website.

Include Google Analytics code in entire site

Have a look through all your settings, and move on to the next step.

4: Publish the Hook Element

Once your Hook Element is created and configured the right way, you can hit that publish button.

Publish the Hook element

Once it’s published, visit some of your posts, and also your home page, to test that the tracking code is present in the HTML source code.

Right click on the page you’re on, select View Page Source, and do a quick search for (a word or phrase in) the tracking code. If you can find your Google Analytics code, you’re all set!

Join Blog Pioneer

​JOIN BLOG PIONEER

​​Subscribe now and learn how to grow your ​blog into a thriving business with effective SEO and monetization strategies.

​​BONUS: ​​3 actionable SEO tips you can implement today to give your blog posts an immediate boost!

 
AJ Mens

I have been running an online business since 2015 and am using Blog Pioneer to help you achieve financial success online.

Leave a Comment