How to Add Google Analytics Tracking Code to your WordPress Blog without a Plugin
Plugins can introduce bugs, security issues, and degrade performance. This tech-recipe demonstrates the most simple and secure way to add Google Analytics to your WP blog (see Step by Step to Install WordPress Manually).
If performing a simple task, do not compromise your site’s security by stacking plugin on-top of the plugin. Adding the Google Analytics tracking code to your blog is very easy to do manually.
Since WordPress creates a dynamic site that is always changing with new content, we need a way for the tracking code to appear on every single page and post. All pages generated within WP are built from some variety of the header.php file. Thus, if we put our tracking code in this header file, we can be assured it will trigger on every view of any part of our WP site.
Step 1: Log in to your WordPress Backend and navigate to Appearance -> Editor
Step 2: On the right of the screen you will see all the files used within the theme of your current site. We are looking for the header.php file. If you are using a custom theme, it is possible that it might not be named this exactly. This is rare, however, as most theme designers use common standards to maintain compatibility. Click the file when you find it and it will open in the editor on this page.
Step 3: Take the tracking code snippet from your Google Analytics admin area. Paste it into the top of your header.php file immediately before the closing </head> tag
Step 4: Click the Update File button to save this file. Refresh some of your WordPress generated pages and see if the tracking code appears in the source code.
Note: Your Google Analytics will take about 24 to 48 hours to config.
Via tech-recipes