How to Add Google Analytics Code to WordPress – No Plugin Needed

How to add Google Analytics tracking code to your WordPress site without a plugin

If you run a WordPress website, you may want to add Google Analytics and Webmaster Tools tracking code to your site.

Google Analytics and Google Webmaster Tools are free tools that can help you see how many visitors are coming to your site and what they are reading, or clicking on.

You can add Google Analytics and Webmaster Tools tracking code to your site in a variety of ways, including using a free plugin to do so…

This post shows you how to add the Google Analytics tracking code manually to your WordPress site without using a plugin.

1. Go to Google Analytics

The first step is to log into Google Analytics and click on the website property you want to verify.

Below your website name, click “All Web Site Data”.

Then click on the “Gear” icon for the “Admin” section of Google Analytics in the lower left-hand corner of the dashboard.

2. Get Your Google Analytics Tracking Code

Click “Tracking info” from the middle column of options.

Then click “Tracking Code”.

Then copy the tracking code from the Admin section of Google Analytics

Then you will paste this code as described below, into the “Header.php” file on your WordPress site.

3. Add Google Analytics Tracking Code to Your WordPress Header.php File

On your WordPress site dashboard, click “Appearance” and then click “Editor”.

From the right side of the Editor, find and click on the “Theme Header” and “header.php” file. 

Paste the Google Analytics code in the header.php file. Paste above the </head> tag and below whatever comes before it. You can see below an example1

4. Update Your Header.php File

That’s it. Now just click the “Update File” button at the bottom. Now you should be able to go into your Google Analytics dashboard and start receiving data from your WordPress site.

Footnotes

  1. This may not be exactly what you see on your own site, so be sure to make a backup of your site first before changing any code in your header.php file