Should You Put Google Analytics Code in WordPress Header or Footer?

Want to know where should you put your Google Analytics code? While it’s safe to put your code in header or footer, Google recommends you to add your code to your WordPress header. Learn the reason behind it and whether adding Analytics code into the header would impact your site.

The Benefits of Adding Analytics Code into Header

If you add your Analytics tracking code to your footer and run a lot of other JavaScripts on your site, chances are Analytics won’t accurately track your traffic data.

It is mainly because JavaScript snippets are triggered in the order they are embedded in your page. Your page may prevent running your footer scripts due to other JavaScript errors or performance issues of other scripts/components.

This is why Google recommends you add your tracking code in the header of your site.

It helps you to accurately record traffic stats because your header scripts are loaded earlier than any other scripts on your page.

In addition, the tracking code loads on your site asynchronously, meaning other scripts can also load simultaneously. For that reason, adding your tracking code into your header doesn’t reduce the page speed or impact your WordPress site performance.

There are many ways to add your Google Analytics code snippet into your WordPress site.

The easiest way is to set up your Google Analytics with your WordPress site using the MonsterInsights plugin.

How to Add Your Google Analytics Code into Header

MonsterInsights makes it easy to add your tracking code into your WordPress header without even touching the code.

After you installed and activated MonsterInsights, you can easily add your tracking code into your header by clicking on the Authenticate it with your Google account button by navigating to Insights » Settings in your WordPress dashboard.

authenticate

Then, you can follow the instructions step by step until you successfully integrate it with your site.

For a more detailed step-by-step tutorial, read setting up Google Analytics in WordPress.

We hope this guide helped you learn about putting Analytics code in your WordPress site.

Once you successfully integrated your website with Google Analytics, you might want to identify your high converting landing pages to optimize your conversions. And don’t forget to follow us on Twitter and Facebook for more Google Analytics tutorials.

Comments

Congratulations, you have the opportunity to be the first commenter.
Have a question or suggestion? Please leave a comment to start the discussion.

Leave a Reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.