How To Add Google Analytics To GeneratePress

A quick tutorial on adding Google Analytics to the GeneratePress theme. (Bonus, you don’t need yet another plugin)

You’ve got to love GeneratePress, either the free version or may fav the pro one it’s just so darn versatile.

I am looking to add Google Analytics to the GeneratePress theme. It will take you roughly around 2 minutes, thanks to how easy GP is to use!

Subscribe for all the latest from LyrWP.

Step 1. Head on over to the appearance menu in your WordPress admin sidebar

Head on over to Appearance > Elements. Click on Elements. Once you have clicked Elements you will be greeted with the below screen:

Add a new element

Add a new element

Step 2. From this section, we need to choose from a dropdown list – Hook.

Select Hook from the choose Element type, Hook nothing else ok?

Step 3. Adding a new Hook (this is where your Google Analytics snippet will live)

Adding Google Analytics to GeneratePress theme

Give your new Hook a name, for tutorial purposes and perhaps your sanity; you might want to call it Google Analytics. Handy if you need to refer back to it later from the archive of Elements.

Step 3. Head on over to your Google Analytics panel

I’m assuming you know how to get your GA code from the admin panel? Well if you’ve set it up correctly, you need to get your code snippet.

To do this:

Click on Admin at the bottom left corner of your Analytics admin (the gear icon) if you’ve added a site, choose which one is applicable from the first column called: Account.

From here wait for the second column to refresh with the appropriate details, 3rd option down is: Tracking info. Click on this, then choose Tracking code. You will then see:

Copy your Google Analytics code
Copy your Google Analytics code

Just highlight the script we’re going to need to copy and paste.  Next.

Step 4. Head back to your newly created Google Analytics hook

Paste Google Analytics code into GeneratePress hook


Paste Google Analytics code into GeneratePress hook

Just paste your Google Analytics script into the box directly underneath the title as above. Told you it was easy, didn’t I? No plugin needed, no tinkering around with code, etc.? That’s the beauty of GeneratePress.

We’re not done yet though, just a couple of little things.

Step 5. Choose storage location of GA code and ensure it’s sitewide

Ok so we’ve added our Analytics code (copy and pasted) now we need to decide where to display it. In the first option entitled Hook, you can choose a load of different options. You’re only really going to need a couple.

Choose to store GA code in the header or footer; some will say store it in the header for faster loading, it’s down to you.

The next tab along which says Display Rules, click on this. You will then have an option for Location; it’s here you need to choose from the dropdown “Entire Site.”

Hit publish.

Step 6. Checking Google Analytics works in GeneratePress!

The last and most important step! Making sure the above works. Easy to do. After hitting publish and if you’re using a caching plugin, clear that. Then open up your website in a new window.

Head on over to your admin panel for GA, make sure you have the right property loaded. Then in the sidebar, click on Real Time, then Overview.

You should see your visit on your site. 

Hope you enjoyed this quick tutorial!

If you liked this quick tutorial and would like to leave a comment or rate the tutorial, please do. It’s your feedback that will help me improve over time. If you’d like to see more GeneratePress tutorials, then please take a look at some of the latest here!

If you could share this, I'd appreciate it!!

10 thoughts on “How To Add Google Analytics To GeneratePress”

  1. I have used GeneratePress for a long time, I did know the GP which allows to insert GG Analytics into website. Your post suggests me do many other things like inserting Adsense Code, Facebook Pixels…or more on Header or Footer.
    Thanks you for your post <3 Will recommend for my friends

  2. Hey Tuan,

    I love GeneratePress it’s a breeze to use and my go to theme. Its very well optimized for SEO.

    You’re 100% right, the tip above could be applied to a wealth of different uses.

    Glad you thought it was useful! Thanks for adding your input ๐Ÿ˜€

    • Hey Lisa,

      Thanks for the comment. You will need to have the Generatepress premium plugin for this tutorial in order to see the elements.

      Apologies if it was not clearly stated.



  3. In the last part of step 5, you left out whether or not you should click on “add location rule” before hitting publish. I’m not sure if you have to or not, just thought i’d point it out.

    Thanks for the tutorial.

  4. Hi!
    It doesnโ€™t work on my generatepress template ๐Ÿ™

    I need to add Analytics and AdSense code but I donโ€™t know the correct way to do it

    • Hi Mario!

      Sorry to hear you are not getting the results you need. I’d be happy to take a look and offer more advice if needs be. Please feel free to visit my contact page and get in touch, please mention this article when using the contact form! ๐Ÿ‘‰

      All the best



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.