How To Add Google Analytics Tracking Code To WordPress

Google Analytics is a tool that helps you track your website traffic. It also gives you valuable insights about your visitors, this way you are able to understand your visitors which would equally be helpful in planning the best strategy for your website.

You can add Google Analytics to WordPress without a plugin and this is what this article is intended to achieve. However, there are several Google Analytics plugin you can install in your WordPress to make enable Google Analytics in your WordPress website. We will cover that as well, but let’s begin the process of adding Google Analytics tracking code to your site without a plugin.

There are a few things you must be conscious about, if you have decided that adding Google Analytics tracking code to your WordPress site is the best option of you.

Firstly, this is not an easy process, when compared with achieving the same result with a plugin, but it is not too complicated to achieve in next to no-time.

Immediately you install the tracking code in your website, you need to know that it is theme-specific. This means, if you ever change your WordPress theme, you must past the Google Analytics tracking code in the new theme. If you forget to add the tracking code, you will lose the data for the number of days it was absent from your site.

Some plugins come with advance features, which as the case may be, could be lacking from a normal manually installation. Unless, you are patient enough to follow the steps provided by Google. Features like file download tracking, events tracking and custom dimensions may be difficult to implement without a plugin, but it is not impossible.

With that said, let’s add Google Anaytics to WordPress without a plugin. This will help you track website visits, Visitor’s behavior, have access to live traffic feed and lots more.

Add Google Analytics to WordPress Without Plugin

Normally, we’d advise anyone editing some files in their WordPress site to backup before proceeded. So, in case something goes wrong, they can always revert to the existing backup without hassles.

Assuming you have created your WordPress backup, head over to your Google Analytics account. If you don’t have, you will need to a create Google Analytics account here.

Now, go to Admin > Create Account. You will be asked to fill some information.

create-goolge-analytics-accountOnce, you have entered the detailsou will see a button, “Get Tracking ID.” Click the get tracking ID button to generate a tracking code for your website.

tracking-code

If you ever need to get the tracking code again without creating a new account. Right inside your current account, go to “Admin” > “Property” > “Tracking Info” > Tracking Code to retrieve your Google Analytics tracking code.

tracking-code

Copy the Google Analytics tracking code in your WordPress site. You can either add it to your header.php file or your footer.php file. I’d recommend adding it to your footer.php file as some study have revealed that adding Javascript code to footer files helps site speed.

Add Google Analytics Code to Header.php or Footer.php file

Log in to your WordPress dashboard > “Appearance” > “Editor.” Now, click the header.php file or the footer.php file on the right-hand side below the Template section.

Now, paste the tracking code you copied from your Google Analytics profile and paste it:

  1. Inside the <head> tag for header.php file or
  2. Just before the </body> tag for footer.php file.

You are to paste this tracking code in either the header.php file or footer.php file and never both.

paste-tracking-code

The next thing you need to do is Update the file and your Google Analytics Profile should start picking information for your site.

To verify this:

Head back to your Google Analytics profile > “Real-Time” > “Overview”

google-analytics-live-feed

That’s it. Google Analytics has been successfully installed in your WordPress site. If you want to use a plugin to achieve this, here is a list of the top 10 best Analytics WordPress pluigns to get you started immediately.

In case you don’t know, MailOptin integrates with Google Analytics so you to view advanced reporting and detailed data on how your lead capture or optin campaigns are performing.

 

Lead Generation & Email Automation Plugin

Install MailOptin today to convert your visitors to email subscribers and engage them with automated newsletters whenever you publish new blog posts.