How to Install Google Analytics for your WordPress Website

In this video I go over briefly how to create a google analytics account and how to install the code on your self-hosted WordPress website to start collection stats.

I actually have two methods to show you. First, I show you how to directly copy and paste the code into your WordPress theme and then I’ll show you how to setup a Google Analytics plugin.

Option 1: Copy Your Google Analytics Code into your WordPress Website

  1. Signup for a Google Analytics Account
  2. Copy the tracking Code
    • If you just signed up then you’ll be redirected to the tracking code page automatically. Otherwise, if you already have an account navigation to the tracking code by going to Admin > Tracking.js > Tracking Code Google Analytics Tracking Code
  3. Copy the code into your Theme’s header.php file
    • Go to your WordPress Dashboard
    • Navigate to Appearance > Editor 
    • Open header.php
    • Paste the code just BEFORE the “</head>” tag Google Analytics Header
  4. Verify the code
    • Within a few minutes, Google Analytics will let you know if it’s picking up the code on the tracking code page (look for “Status: Receiving Data”) Google Analytics Tracking Code


Option 2: Install A WordPress Plugin to Collect data for Google Analytics

As an alternative, you can install a plugin that will install that Google Analytics code for you


A plugin will give you a snapshot of your stats in your WordPress Dashboard 

AND (what I think is most important)

It will exclude all of YOUR visits to your website. ie: If you are logged into your WordPress website and preview content, test out form, etc – all your data doesn’t get tracked.

So here are the steps to get your plugin install and working with google analytics. 

  1. Signup for a Google Analytics Account
  2. Install Google Analytics Dashboard for WP Google Analytics Dashboard For Wp
    • Go to your WordPress Dashboard
    • Plugins > Add New
    •  Search for Google Analytics Dashboard for WP 
    •  Install
    • Activate
  3. Go to Google Analytics (a new menu item on your sidebar)
  4. Enter the Access Code
  5. Go to Tracking Code Select “Administrator” (and other roles that you don’t want to track)

Et Voila! Now you have Google Analytics setup for your WordPress website!

Here’s a video going through all the steps outlined above


[Tweet “How to install Google Analytics on your WordPress website via @aprettierweb”]

5 thoughts on “How to Install Google Analytics for your WordPress Website”

  1. fabulous tutorial! I’m loving the dashboard plugin – thank you! I’m a total blog newbie, so this was an easy straight forward tutorial for me to follow. Can’t wait to browse your site for more tutes 🙂 thanks!

Leave a Comment

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

I’m a WordPress Web Designer & Developer with over 15 years of experience making websites (including eCommerce and membership websites). If you would like a custom website, please get in touch!