How To Add Google Analytics Code To GeneratePress Theme?

Looking for a method to add Google Analytics code to GeneratePress?

GeneratePress is one of the best WordPress themes that has really made designing a WordPress site truly easy for beginners with its easy-to-use customization options.

It’s been more than 5 years for me using the GeneratePress premium theme almost on all my WordPress powered blogs and websites.

This one theme can make it easy for you to achieve any kind of design you want, whether you are creating a website for your digital agency business, your portfolio or anything else.

It’s really fantastic! You can learn more about the GeneratePress theme in this detailed review here…

Let’s don’t get distracted from the topic, so you are looking at how to add Google Analytics code to the GeneratePress theme.

It’s quite easy! I will show you the same in this post. You just need to follow the steps that I will write down for you to add Google Analytics tracking code to GeneratePress.

What Is Google Analytics Tracking Code?

Google Analytics’ tracking code is a unique identifier that connects your website/app to Google analytics and collects the users’ data.

Once the code is inserted into your website properly, you will be able to get your website traffic data inside Google Analytics.

In simple words, you can say tracking code works as a middle man to connect your website with Google Analytics.

With the help of these few lines of JavaScript, you’ll be able to track every activity of users on your website.

You can find the sources they come from, their county, devices they are using and many other useful data which can help significantly in the growth of your business.

Where To Find The Tracking Code In Google Analytics?

When you are adding a new property to your Google Analytics account, you will be automatically asked to add the code and code snippet will show on your screen.

If you want to find the tracking code of your existing property in Google Analytics then follow the below steps:

  • Login to your Google Analytics Account.
  • Once you’re inside Google Analytics, click on the Admin and then select a Property for which you want to find the tracking code.
  • Navigate to Property > Tracking Info > Tracking Code.
  • You get the code…
Add Google analytics tracking code in Generatepress

Copy the entire code to proceed to the further step.

How To Add Google Analytics Tracking Code In GeneratePress?

Well, adding the Google Analytics code in GeneratePress isn’t tough as it looks… It can be done using methods that work with the other themes.

In this post, I will show you two methods to add Google Analytics code in GeneratePress.

  1. First method — Using the 3rd party plugin
  2. Second method — Using GeneratePress Hook element

Before we proceed further, make sure you have already copied your Google Analytics tracking code. You can find the code using the above steps…

Add Google Analytics Code To GeneratePress (Using 3rd Party Plugin)

There are tons of plugins that can help you in this, but Insert Headers and Footers is what I and most other WordPress users use for adding the GA tracking code to their WordPress site.

Basically, this plugin lets you add any external code to your website’s header or footer.

Go to Plugins>Add New and search for the Insert Headers and Footers plugin in the search box to install it on your site.

install insert headers and footers

Click on the Install button to install the plugin and then Activate it to make it live on your website.

Once the plugin is live on your WordPress site, you are ready to add your tracking code.

To add the code, go to Settings>Insert Headers and Footers.

You will see three boxes there, Scripts in Header, Scripts in Body and Scripts in Footer. Paste your GA tracking code inside Scripts in Header box.

insert headers and footers

Don’t forget to scroll down and hit the Save button to make your changes live. You’re done!

Add Google Analytics Code To GeneratePress (Using Hook Element)

If you don’t want to install an additional plugin just to add a few lines of tracking code to your website then this method is suitable for you.

GeneratePress allows its users to add code snippets anywhere in their website using the custom hooks element. You can use the same to add Google analytics tracking code too.

Here’s what you need to do:

  1. Go to Appearance>Elements.
  2. Click on the Add New Element.
  3. Choose Hook as Element type and hit the Create button.

Now enter a title to remember what you used this Hook for in future and paste the tracking code inside the box just below the title.

Google tracking code in generatepress hook

Choose the wp_head in the Hook position in the settings. It is always recommended to place the tracking code in the header to get accurate traffic stats.

Now, let’s set up the Display Rules, select the Location as Entire Site because you want to let the code run on the entire site.

After setting it up, click on Publish from the right sidebar.

display rules

It’s done! You’ve successfully added the Google Analytics code to your website. Don’t forget to clear the cache and verify the integration by testing with test traffic.

Conclusion

I have shared the two reliable and most preferred methods to add the Google Analytics tracking code to GeneratePress powered websites.

If you don’t want to install an additional plugin just to add some lines of code then the second method is suitable for you.

Consider sharing this article with other GeneratePress theme users and let them be aware of these methods to add Google Analytics code to GeneratePress theme.

Also, drop your queries in the comments section.

Also read:

Photo of author

About Ravi Dixit

Ravi Dixit is the founder of StayMeOnline, a full-time blogger and affiliate marketer since 2016. He helped many people in starting their own profitable blogging journey and earning decent money from blogging. Apart from blogging, he loves travelling a lot.

One Humble Request!

I’ve put a lot of effort and done lots of research into writing this post to provide value to our blogging community. I will be glad if you share this post on social media. Sharing is caring ?

0Shares
StayMeOnline Facebook group

JOIN OTHER LIKE-MINDED PEOPLE

  • Get Free Help From Experts
  • Daily Actionable Tips To Grow Your Blog
  • My Secret Strategies
  • Free Bonuses & Giveaways

Leave a Comment

Share via
Copy link
Powered by Social Snap