September 28, 2016

How to Add Google Analytics to WordPress

You’ve just set up a brand new WordPress site and you’re ready to start bringing customers into your business. Weeks have gone by, and you don’t know whether your customers have visited your site, whether your ad spend has really converted into any sales, or how your customers are navigating through your site. If this is you, then it’s time to learn how to add Google Analytics to WordPress and start tracking how your customers use your site.

Google Analytics is a powerful tool that allows you to see how your customers interact with your site. By looking at the data, you’ll have a better understanding of which marketing channels perform best, or if there are landing pages that need to be improved. Let’s get started and teach you how to add Google Analytics to WordPress!


Setting Up Your Tracking ID

First, head over to to get started. Create an account if you haven’t already. You’ll need to fill in the information as it’s related to your account. I filled in a sample here:



Once you have finished, entering in the correct settings, click “Get Tracking ID”.




When you click the button, you’ll be sent to the next page that has your Tracking ID as well as your javascript code you’ll be inserting into your site. If you have a WordPress site, like ours, you’ll be inserting this code into your header.php file just before to </head> tag.  So what you’ll need to do is copy this code:




Inserting Your Tracking ID Into Your Website

Head over to your WordPress Admin page so that we can easily insert it into our header.php.


On a side note: If you have a WordPress theme that receives updates periodically, I suggest not using the method below and instead use a third party plugin, like Monster Insights.


To put in your Tracking ID as simply as possible, go to your WordPress Admin page and go to Appearance->Editor.




When you get to the editor page, select Theme Header on the right sidebar to bring up the header.php editor.




All you need to do is add the javascript code that you copied from analytics and insert it into the code like this:




Next, hit Update File and you’re good to go!



You now have learned how to add Google Analytics to WordPress.  Now that you have Google Analytics tracking your site, you can now set filters and goals. This will let you track exactly what information is relevant to your business.
Consult with your developer to make sure that you’re getting the most out of your marketing campaigns. Using Google Analytics, Google Adwords, and Google Tag Manager will greatly help you achieve your goals. If you’d like to discuss how we can increase your site traffic, please contact us for a free consultation.




Fields marked with an * are required