Tracking Search Rankings in Google Analytics

  • follow us in feedly
Published April 19, 2013 by Brad Knutson
Google Analytics Tracking Keyword Ranking

Tracking your search rankings can be a daunting task if you choose to go it alone. SEOmoz is a great tool for tracking your rankings, and you can sign up for a free trial if you would like. Still – many marketing departments and small businesses on a budget find their own ways to track their search rankings for various keywords.

You could enter your relevant keywords in Google and track them in a spreadsheet over time, but that could be a tremendous amount of time and effort to get a small amount of useful data.

Finding valuable information in referral links

Google gives us some very useful data in it’s referral link. Believe it or not, Google actually passes along the rank in the referral URL. As we know, if the user from Google is logged into any Google product we lose the keyword data (which is replaced with the infamous not provided keyword in Google Analytics) – however Google does pass along the ranking data.

Let’s take a closer look at some referral links. If you go to Google, run a search, right-click on a search result and choose “Copy Link Location” you’ll see the same URL structure below. We’re keying on two query string variables, the first is the q= variable which is the keyword, and the second is the cd= variable, which is the rank.

User not logged into Google,d.aWc

User logged into Google,d.aWM

The two referral URLs above are identical searches ran on two different browsers – one logged into Google and one not. Both produced the same top result for the keyword “web designers” and both passed along the correct rank. As expected, the browser in which I was authenticated through Google failed to pass along any keyword data.

To make sure that the rank is accurate, I flipped to page 5 of the search results and pulled the referral links again. This time around, the result I targeted was ranked slightly different depending on whether or not I was logged in to Google or not, but some difference is expected based on Google’s personalized search results.

User not logged into Google,d.aWc

User logged into Google,d.aWM

I personally certify the rank variable that is passed along through the referral URL as accurate. Try it out for yourself if you would like.

This is all well and good, but now we need a way to grab this data and analyze it.

Data Gathering Setup and Implementation

Experienced webmasters could probably write scripts to pull this data directly from the server logs. The advantage of this is that you would instantly have the data for the history of your site – as it’s already there in the logs, it just needs to be mined and formatted into a report.

For those that don’t have access to the server logs, don’t have the ability or time to manipulate the data, or those that just prefer an easier alternative – we can grab this data and display it in Google Analytics.

To make sure you don’t make any unwanted changes to your current Google Analytics profile, before we do anything else – create a new profile. I’ve also found that what I’m about to show you works best with a new Universal Analytics property as opposed to the Classic Analytics that we’re all used to using. If you don’t already have one, go ahead and start fresh by creating a new Universal Analytics property (see directions for creating Universal Analytics properties). When you have this set up, create a new profile and name it accordingly (I chose the easily recognizable “Rank Tracking”). Of course, the one downside to creating a new Universal Analytics account is that you’ll have to add another tracking code to your website if you don’t want to discontinue your original account. See the KissMetrics link above for more information on switching to Universal Analytics, it’s consequences and benefits.

The next step is to create a new filter. In the Google Analytics admin, click the Filters tab and choose +New Filter.

Google Analytics Create New Filter

Name the filter whatever you would like. I like to use naming conventions that will be easy to understand months from now when I forget that I’ve implemented them. Perhaps you could use “Google Ranking Tracking” for the name.

Fill out the form with the values in my image below. You’ll need the following two regular expressions – I’ll explain what they do in a moment, and a third value to tweak the output.



$A2 (rank: $B2)

Google Analytics Setting Up Filter

The first regular expression matches the keyword in the referral URL, and the second regex matches the ranking variable. These are stored in their respective variables, $A2 and $B2, and used to create new output.

You can choose require field A, but rather than seeing (not provided) over and over again, I choose to not require it.

Reporting and Viewing the Data

Now that we have our filter set up, we just need to wait for the data. The beauty of creating a separate profile is that your original Google Analytics data is not affected by the filter that we just created – and the new keyword and ranking data we are pulling can be easily viewed by pulling up the new profile.

After you’ve let the account sit for a while and gathered some good data, you can pull up the report. Pull up Traffic Sources > Sources > Search > Organic and take a look at your data. You should see a combination of your keywords and rankings.

Google Analytics Tracking Ranking Keyword

As you will notice right away, your keywords won’t be formatted perfectly, you’ll have strings (either + or %20) that replace spaces – but the data is all there. Each keyword will show it’s ranking in the format we specified when we created the filter.

One thing I noticed is that any lines without the ranking actually mean they are from Google Image Search. Unfortunately, Google Image Search results don’t carry a ranking variable along with them.

But what about those pesky (not provided) keywords? As usual, there is no way to get the keyword data back, but we can gather some other useful information from it.

To get some useful data from keywordless entries, set the Secondary dimension to Landing Page.

Google Analytics Tracking Ranking - Landing Pages

This data can be very useful in determining how your individual articles are ranking for longtail keywords at a broader level. Depending on the frequency of some high ranking keywords, we can also deduce what keyword it is based on our other keyword and ranking data. This gives us a new window into some of the data that we lost with (not provided).

So what do you think? Would this be something you would consider setting up on your Google Analytics account? Do you have a better way of tracking keyword rankings? Leave a comment below!

The following two tabs change content below.
Founder at Inbounderish
Brad Knutson is a Web Developer in the Twin Cities area of Minnesota. He has experience working with WordPress and Drupal, and also has an interest in SEO and Inbound Marketing.

Keep Up-to-Date



See a complete list of topics discussed in blog posts here.

Check These Out

Get 2 Weeks Free! Sign Up Today! Premium Managed WordPress Hosting Genesis Framework for WordPress SEO is complex. Tools should be simple. Thesis Theme for WordPress:  Options Galore and a Helpful Support Community

Share Your Thoughts

Your email address will not be shown.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">