How To: Add Google Analytics Code to WordPress Manually

I have already posted a WordPress plugin recommendation on the plugin “Google Analytics for WordPress” and it works great. But there is a few things that I personally find annoying. First of all, it not only adds the Analytics code to the header, but also “Powered by blah blah blah” and I find that egotistic of the developer. Secondly it’s the general placement of the code, in the header, which means that the visitors web-browser will load that as one of the first elements of the page. Which will slow down the download of the main content, which is very important to me. Next I will show you how you can add the code manually to your WordPress footer.

The first thing you need to do is to get your hands on the Google Analytics tracking code, and you can do that by first going to Google.com/Analytics and logging in. Then you need to click “Edit” to the far right of your profile. Then click “Check Status” in the top right corner and there you have your tracking code. Copy the code or leave the webpage open cause we will need it later.

Now, go to your WordPress dashboard (admin panel) Appearance > Editor and click “Footer (footer.php)” on the right side of the page. Scroll down in the editor window and paste in the Google Analytics tracking code in between the </body> and </html> tags, so that it looks like this:

Click “Update File” and you’re done! Remember that it may take 24h or more before the Google servers update properly.

2 responses to “How To: Add Google Analytics Code to WordPress Manually”

  1. I already installed the WP Plugin for Google Analytics… but I have no results in my analytics dashboard. I’m fairly certain I entered the code correctly, etc.

    So, thought it might be best to do this manually. I’m more familiar with static html sites, so glad I found your post.

    The footer sounds like a good idea… so, if I understand correctly, this will give us results for ALL the pages in the site? Hope you can reply…

    Thanks!
    Christine

    • Yes, you are correct. It will affect ALL WordPress posts and pages. By placing it in the footer, every browser will read the analytics JS last and all of the good stuff first.

Leave a Reply

Your email address will not be published. Required fields are marked *