How To Add Google Analytics To WordPress Blog Post

How To Add Google Analytics To WordPress

In The Digital Marketing Blog by SeanLeave a Comment

Adding Google Analytics to WordPress can be done by using one of four methods:

  1. Adding Google Analytics to WordPress using inline tracking code.
  2. Adding Google Analytics to WordPress using plugins.
  3. Adding Google Analytics to WordPress using Google Tag Manager (GTM) via inline code.
  4. Adding Google Analytics to WordPress using GTM plugins.

There are a few things you’ll need to have in place before you start:

  • A Google Account
  • A Google Analytics Account
  • If using Google Tag Manager (GTM), you need a GTM Account and Container with the GA pageview tag installed

Critical – Plan the best method for adding Google Analytics to WordPress

Take some time to research and consider which method is going to work best for you. T

his would warrant a separate blog post, but broadly speaking, be guided by your requirements, the resources available to you and the level of technical skills at your disposal.

Smaller sites with limited technical resources may opt to use plugins, while larger enterprise WordPress sites with technical teams will likely prefer an inline code approach, but…

There is no right or wrong way. 

Let’s dive into the methods available to you, starting with Inline Tracking Code.

Method 1: How To Add Google Analytics to WordPress With Inline Tracking Code

CAUTION

If you’re nerdy, you can do this yourself, but when making inline tracking code changes, it’s important to:

  • Always consult your theme documentation before proceeding.
  • Remember that editing code is not without risk. Always make a copy of your header.php file with a different name before you make and save any changes to your WordPress site.

E.g. make a copy of your header.php file and rename the original header-old.php That way, if you break the code, you have a fully working version to revert to 😊.

It’s also best practice to work on a child theme of your site. This is because when you update your theme, the files you edited will be overwritten, removing your Google Analytics tracking ☹

If this sounds overwhelming or too challenging, follow the instructions for using plugins instead for a simpler life.

The 3 Steps to Add Google Analytics to WordPress with Inline Tracking Code:

  1. Step 1. In your WordPress theme, you’ll need to locate the template where the HTML <head> information is located. It’s commonly found in the php file.
  2. Step 2. In Google Analytics, copy your GA Property tracking code (admin > PROPERTY > Tracking Info)
  3. Step 3. Edit the php file using WordPress’ editor (admin > settings > editor) and add the tracking code in the opening <head> section of the site.

But, let’s take a look at the pros and cons of adding Google Analytics to WordPress via Inline tracking Code:

Google Analytics Inline Pros

  • Locates the tracking code according to Google best practice in your HTML
  • You’ll have full control of your tracking code
  • Code is customisable

Google Analytics Inline Cons

  • Must be done in your child theme
  • Requires you to update code changes manually
  • Requires technical skill for customisation and can be easily misconfigured
  • Adding lots of inline tagging can bloat the HTML source code, adversely impacting page speed performance

More information

Find more support with the guides below:

https://www.hermesthemes.com/add-google-analytics-wordpress-website/

https://optimizerwp.com/wordpress-child-theme/

Method 2: How To Add Google Analytics to WordPress With Plugins

For many small operations and one-person setups, the technical challenges and extra customisation requirements when using inline code are blockers.

As such, adding Google Analytics to WordPress via Plugins can be super useful in these instances.

Pros & Cons of Adding Analytics to your WordPress site via a Plugin:

But first, what are the pros and cons of using plugins to add Analytics to your WordPress site?

Pros

  • Quick
  • Easy to use
  • Offers a wide range of built-in ‘advanced’ customisation deployed at the click of a button, e.g. Event tracking.
  • Offers some useful extras like dashboard reporting in WordPress
  • Frequently updated by third parties
  • Some offer GTM support 😊😊😊

Cons

  • Limited tracking code customisation
  • May lack specific features you need
  • May negatively impact site performance (too many plugins)
  • Free plugins might lack good support, leaving you in limbo when a problem strikes
  • Adding additional analytics tracking tags will require even more plugins (unlike using GTM)

To get you started, we checked out three WordPress plugins with a high volume of downloads and good user ratings.

1.     Google Analytics Dashboard For WP (GADWP)

Pros

  • Free
  • Widely used: 1+ million active installs
  • Good selection of dashboards to view in backend or to add to posts
  • Advanced Google Analytics configuration settings with full code customisation options
  • Event tracking
  • Custom Dimension tracking
  • GTM tracking
  • Accelerated Mobile Pages (AMP) tracking for GTM
  • E-commerce support

Cons

  • Limited support

You probably noticed this plugin includes Google Tag Manager integration – so it could be used for Method 4: Add Google Analytics to WordPress using GTM plugins too.

2.     Analytify Plugin for WordPress

Pros

  • Reasonably priced with support included
  • One-click installation
  • Easy to use
  • Dashboards for page level, social media, custom posts and real-time stats reporting
  • Publish dashboards to the WordPress frontend page to share with teams
  • Enhanced E-commerce tracking/reporting with WooCommerce or Easy Digital Downloads
  • Automated email reporting
  • Custom Campaign reporting

Cons

  • Paid plugin
  • Lack of advanced configuration settings
  • No GTM option

3.     Enhanced Ecommerce Google Analytics Plugin for WooCommerce

This plugin is for e-commerce sellers using WooCommerce

Pros

  • Good support
  • Tracks Enhanced E-commerce on WooCommerce sites
  • Includes Shopping Behaviour Report, Checkout Behaviour Report, Product Performance Report, Sales Performance Report
  • Option to upgrade to paid version with advanced enhanced e-commerce tracking and full support (great value)

Cons

  • Not recommended with GTM
  • Requires support if using a child theme
  • Out of the box version does not provide for customised store or store using WordPress child theme. Check feature support carefully.

Tatvic’s plugin packs a lot of power!

That wraps up the plugin options so next, we’ll look at some of the Google Tag Manager options for WordPress.

Method 3: Add Google Analytics To WordPress Using Google Tag Manager Inline Code

Implementing Google Tag Manager tags inline follows a similar process to adding Google Analytics inline.

Follow these steps to add Analytics to WordPress using Google Tag Manager Inline Code:

  1. Sign in to your GTM Account https://tagmanager.google.com/.
  2. Locate your GTM container which contains your GA Tag.
  3. Click on your GTM ID.
  4. Copy the code which goes in the <head> of your WordPress template.

Follow the instructions for adding GA inline code to WordPress to add your GTM container to WordPress.

Pros and Cons

The pros and cons are pretty much the same as adding GA code inline.

Method 4: Add Google Analytics to WordPress Via Google Tag Manager Using Plugins

Plugins are a quick and efficient method of adding Analytics to WordPress and here are two popular plugins to consider if you’re going down the Google Tag Manager route:

DuracellTomi’s Google Tag Manager for WordPress

https://en-gb.wordpress.org/plugins/duracelltomi-google-tag-manager/

Pros

  • Free
  • Works out of the box and is easy to set up
  • Tracks WordPress post/page titles, dates, category names, tag names, page ID, author ID, author names, logged-in status and more.
  • Event Tracking for Contact 7 forms and social media
  • Weather and browser / OS/device data tracking (beta)
  • Classic E-commerce
  • Enhanced E-commerce tracking (beta)
  • Google AdWords Remarketing
  • Scroll tracking
  • Tag blacklist/whitelist options
  • YouTube, Vimeo and Soundcloud Event tracking

Cons

  • Reported problems with social media tracking
  • Free plugin so there may be some issues with answering support requests
  • Requires editing the WordPress theme to install it in the HTML <head> of your WordPress site templates following Google’s best practice

Metronet Tag Manager
https://en-gb.wordpress.org/plugins/metronet-tag-manager/

Pros

  • Simple, frills-free
  • Customisable
  • Allows you to add Event tracking to WordPress links
  • Allows you to easily add HTML IDs to any WordPress content using the WordPress page editor

Cons

  • Plugin text copy looks outdated
  • Requires some technical knowledge to create and add dataLayer.push code to HTML for Google Analytics Event tracking

So, there you have it, 4 different methods for adding Google Analytics to your WordPress site. If you have any questions on this or have something useful to add which will help others based on your experience, don’t be shy – drop a comment below! ­­­

Related Posts:

What is Google Tag Manager?

How To Install Google Tag Manager

Event Tracking With Google Tag Manager

How To Check Google Analytics Code On All Pages

If you’re getting started with Google Analytics and are looking for some help, why not get in touch. You can find out more about our Google Analytics services here or feel free to call us on 01273 733433 or get in touch using the form below. We’d love to help!

Contact Us

  • This field is for validation purposes and should be left unchanged.

Leave a Comment