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!
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
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)
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:
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
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.”
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!