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’m going to show you how to add Google Analytics to the GeneratePress theme. It will take you roughly around 2 minutes, thanks to how easy GeneratePress is to use!

On to the tutorial itself

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

Add a new element
Add a new element

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

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

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

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

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

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.

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 infoClick on this, then choose Tracking code.

Copy your Google Analytics code
Copy your Google Analytics code

You will then see the image above. Just highlight the script we’re going to need to copy and paste.  Next.

Head back to your newly created Google Analytics hook

Paste your analytics code
Paste your analytics code

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.

Choose storage location of GA code and ensure it’s site wide

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.

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 about it, 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!


Subscribe To My Newsletter 🚀

I hate spam; you do as well, come on, you know you hate it. I don’t spam. Simple. Join 48 others and sign up if you’d like to hear more from me.

By subscribing you agree to receive newsletters and agree with my Privacy Policy. You may unsubscribe at anytime.
Default image
Ben
Hey I'm Ben. LayerWP is where I spend most of my time. Creating content for WordPress beginners, reviewing themes/plugins, offering advice and tips and tutorials.

Leave a Reply