Blog

A blog about data-driven marketing.

EasyAutoTagging – Built to Automate Campaign Tagging & Tracking at Scale

Learn More

3 Simple Ways To [Quickly] Add Google Analytics to WordPress

Estimated Reading Time: 7 Minutes

Measuring website user behavior whether it is to consume content or make a purchase is vital which is why I put together a post on how to add Google Analytics to WordPress.

Why WordPress? WordPress is a super popular platform, and according to some of the most recent stats, 30% of the web is powered by WordPress.

That coupled with over 40 Millon sites using Google Analytics to track site visitors means that there is a shi**oad of Google Analytics WordPress out there.

Since a proper Google Analytics install is critical to accurately tracking users, I provide three different approaches on how to Add Google Analytics to WordPress.

How to Add Google Analytics to WordPress Using a Plugin

The first and easiest way to install Google Analytics on WordPress is to use a Google Analytics WordPress plugin. You can go two ways with this approach.

Simple

If you want to get the tracking code in place and are not looking for any additional features, you can use GA Google Analytics a Google Analytics WordPress plugin built and maintained by Jeff Starr.

This is a simple way to get up and running quickly.

Robust

However, there are more robust Google Analytics WordPress plugin options available if you are looking to pull in reporting dashboards directly into your WordPress site.

Such as Google Analytics for WordPress by MonsterInsights and Google Analytics Dashboard for WP by ExactMetrics

Many of these Google Analytics WordPress plugins also have granular tracking and some customization features that can be applied.

Keep in mind that the more robust tools require a more extended setup and also work on a freemium pricing model.

The drawback with relying heavily on plugin functionality is potential compatibility with your site, lack of unique customizations and dependence on the plugin working correctly with the Google Analytics API. (future proof)

How to Add Google Analytics to WordPress with a Header & Footer Script Inserter

You can also add Google Analytics to WordPress by placing the Google Analytics script in one of these plugin fields.

That is if you are not working with a framework, i.e. Genesis or Thesis which already have a script field built into their Framework. For example, Genesis provides the following field under settings.

 

How to add Google Analytics to WordPress

 

If you are working without a Framework and are using the native WordPress install, you can use a plugin for adding WordPress Google Analytics script.

For example ‘ Head and Footer Scripts Inserter’ allows you to Hook into the Header and Footer sections of your site adding custom tracking scripts.

Alternatively, if you can access your functions.php file and are comfortable making edits you can always Hardcode the Google Analytics WordPress Script in the Functions File.

This is pretty straightforward, and you can reference these sources for the specific code:

Genesis

Thesis

WordPress

Install Google Tag Manager on WordPress

For the third option, you can install the Google Tag Manager plugin then install Google Analytics via GTM to Add Google Analytics to WordPress.

This is the more robust and most flexible version.

If you ask me it is the best approach since you are setting yourself up to be highly flexible with the ability to customize your tracking on an ongoing basis.

You are also not limited to Google Analytics tracking and can install other essential tracking snippets such as the Facebook Pixel.

The plugin I use for this is
DuracellTomi’s Google Tag Manager for WordPress it is super powerful works seamlessly for Google Tag Manager and can even push page meta info into data layers.

I will cover the basic set up for the Google Analytics tracking here, but these set of tools have so much more to offer.

So if you are an expert knock yourself out 🙂 and if you are a beginner then as you learn and expand your tracking and analytics expertise you are already set up for success.

Setting Up The Google Tag Manager Plugin

Ok let’s get started:

(The assumption is that you already have a Google Analytics and Google Tag Manager account and of course a WordPress site)

First, go to the plugin page and download the plugin file.

Then upload the plugin to your WordPress site and activate it.

Alternatively, you can search for the plugin in the directory and install it that way.

Once the plugin is active, let’s go over the basic set up.

You can find the plugin under Settings > Google Tag Manager

First Enter your GTM Container ID

I have the no script file set to off – This code is only executed if for some reason the user has Javascript disabled.

 

How to add Google Analytics to WordPress

 

Interesting Fact: According to Stats from Blockmetry only 0.2% of worldwide page views from all devices have JavaScript disabled.

The other tab I will cover briefly is Posts under the Basic Data tab. This writes data layers to the source code that you can then use in Google Tag Manager.

 

How to add Google Analytics to WordPress

 

You can see I have Post type, Category and Tags selected.

Pulling these into the data layer allows me to create custom firing rules in Google Tag Manager.

You can learn more about the plugin and in the support section.

Setting Up Google Analytics With Google Tag Manager

Since this post talks about how to add Google Analytics to WordPress, I will include the basic set up of Google Analytics in Google Tag Manager. For a more comprehensive guide you can reference this complete guide to adding Google Analytics to WordPress from Tommy Griffith.

First, go to your GTM account, click create a new tag and give it a name.

 

How to add Google Analytics to WordPress

 

Choose Universal Analytics as the Tag Type.

 

How to add Google Analytics to WordPress

 

Set you Track Type to Pageview Enbabel the Override Setting and enter your Google Analytics ID or Constant Variable containing the ID.

 

How to add Google Analytics to WordPress

 

Now add the trigger to fire on all pages.

 

How to add Google Analytics to WordPress

 

Click save, and your Tag should be all set.

Before you publish hit preview and make sure the tag is firing correctly.

 

How to add Google Analytics to WordPress

 

If all looks good, you can submit and publish.

Note: To validate tracking I always use the Google Tag Assistant chrome extensions. Well worth the install 🙂

Conclusion

If you cannot measure how people are interacting with your site, then you do not know what actions are driving conversions.

Besides, if you capture inaccurate user data, you could be making misinformed vital decisions that negatively affect conversions.

Tracking users is essential but tracking users accurately is critical.

What set of tools have you made use of to Add Google Analytics to WordPress?

Do you rely on a Google Analytics WordPress plugin or find them too limiting?

Leave a comment

Your email address will not be published. Required fields are marked *