HomeInternetWordPressAdd Google Analytics Tracking Code to your WordPress Blog without a Plugin

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.

If performing a simple task, do not compromise your site’s security by stacking plugin on-top of 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.

1. Log in to your WordPress Backend and navigate to Appearance -> Editor

Wordpress Appearance Editor menu

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.

Wordpress File Editor

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

Wordpress editing file in dashboard

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.

Wordpress Update file

Remember, with Google Analytics you will not start seeing traffic info for up to 24 to 48 hours.

Chris Luongo
Chris Luongo
Chris is a self-taught web designer and developer out of Atlanta, GA. This geek enjoys coffee, cold brews, bike riding, and twisting any form of tech into submission.
RELATED ARTICLES

6 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android