My Two Cents on Where to Add Google Analytics in WordPress

There are already enough blogs out there with tutorials on how you can add Google Analytics to your WordPress site.  I won’t bother repeating that information here, but I wanted to add my 2 cents to the discussion.  If you plan to add the tracking code manually, Google actually instructs you to place it right before the HTML header closing tag (i.e. </head>), but I recommend you place it right before the HTML body closing tag (i.e </body>).  Why?  Because while hand coding another website and using Google’s own PageSpeed tool which provides optimization recommendations, it says I should defer the parsing of JavaScript in order to improve performance (i.e load time).  And that’s really easy to do if you’re using one of the default themes.  Just go to Appearance -> Editor and click on the Footer link (i.e. footer.php) on your right.  Scroll all the way to the bottom and place the Google Analytics tracking code right in between the <?php wp_footer(); ?> and </body> tags.  Then click on the Update File button.