Google Analytics and WordPress
As part of an ongoing web project I’m working on for a friend, I have been looking at WordPress and Search Engine Optimization (SEO) with a view towards improving overall Google rankings for a particular web site – http://faceworksevents.com. The first step was to integrate the site with Google Analytics to get a baseline feel for current web traffic.
Be sure to see the Useful Links section for some great resources 🙂
Whenever you work on a customer’s site to improve traffic, you first want to know how much search traffic actually ends up on the site. This turns out to be easy as pie with WordPress – simply grab the Google Analytics for WordPress by the master WordPress’er Joost de Valk (aka “YOAST”) and install it. To enable Analytics, there are a couple things I had to do because the automatic Analytics registration link provided on Yoast’s plugin editing page didn’t work. The steps to get the Analytics API key are as follows:
- Create a Google account. This is easy, simply go to the Google Accounts Signup Page and fill in the information. While you’re at it, be sure to provide a picture as you can use that later in this process to get your picture listed next to search results. Way kewl!
- Add the Google Analytics application to your account. Google Analytics is just one free feature from Google among dozens of of options. To add Analytics, simply click on the “Products” link from your Google Accounts page and select Analytics as one of your products. For this set of SEO testing I did not bother to change any of the default Google Analytics settings.
- Add your web site as a “Profile” to Google Analytics. For Analytics to work properly, you need to make sure your target web site is registered to it. This was a bit confusing to me due to the Google user interface (call me braindead if you will, but I found it confusing). It turns out to be simple:
- Go to https://www.google.com/analytics/ and sign in.
- Initially your list of “Profiles” shows up as empty. Click on the “Admin” link to create your profiles, which in this case for Google Analytics are simply references to the list of Web sites you want to track as shown below.
- Create your Account and then your “Properties”. In the screen shot below, I’ve created an account named “Andy” and a property named “Andy’s WP” that references my entire Web site (the “profile”, which has recently been renamed to “view” by Google – thanks a lot!). To create the account and property, click on the relevant menu and select the appropriate “Create New…” option. The below shot shows how I created my account, property, and profile as well as the “Create new account” option which Google makes available.
- Get your Google Analytics “UA” Code. For Yoast’s Google Analytics plugin to work correctly, the user agent (UA) code must be entered. Yoast’s WordPress plugin provides a function to get this automatically in his plugin but it did not work for me. Fortunately it’s way easy to get this from Google Analytics itself. Once you’ve created your account, property, and “profile” (Google now calls this “view”) then the UA code shows up on the screen. The following shot shows the screen with the UA code on it:
- Enter the Google Analytics “UA” Code into Yoast’s Analytics WordPress plugin. This is the easiest part. The screen below shows the Analytics code entered into the plugin:
- Ignore WordPress logged-in users. Before you continue, first select to show the “Advanced” options within Yoast’s Analytics WordPress plugin as in the picture below:
Then scroll down the Yoast Analytics WordPress plugin options and be sure to indicate that logged-in users do not appear in the counts. Otherwise we skew our results!
But wait…what about logged-in users? Well, to verify that they do *not* affect Google Analytics page view counts, login to your WordPress site and check out page source. You’ll see that the Google Analytics code simply doesn’t appear!
At the end of the day, you have Google Analytics that you can review 🙂 To get to them, simply login to Google Analytics as described above and you can see the current set of page views and the average duration. You must be patient for this; the analytics can take some days to kick in and display!
That’s it for this article! It only scratches the surface of what you can do with Google Analytics within WordPress. Be sure to review the other advanced options especially the ability to create up to 5 user-defined variables that help in fine-tuning Google Analytics tracking.