Skip to content

Cyber Sale: Save big on Moz Pro! Sign up by Dec. 6, 2024

Analytics 2eba248

Getting Rankings into GA Using Custom Variables

John Doherty

The author's views are entirely their own (excluding the unlikely event of hypnosis) and may not always reflect the views of Moz.

Table of Contents

John Doherty

Getting Rankings into GA Using Custom Variables

The author's views are entirely their own (excluding the unlikely event of hypnosis) and may not always reflect the views of Moz.

Gathering rankings is one of the most annoying and time consuming tasks of an SEO consultant's work. Because of search personalization, it can be near impossible to find accurate rankings for keywords to report to clients or to use to gauge our work's effectiveness.

Michael King and I have found a way to get rankings for the keywords driving traffic to your site directly into your Analytics using Custom Variables. Not only that, but we can also get international rankings based off of the keywords and the location from where the person came. And finally, this may also be a step towards identifying the identity of the (not provided) keywords we are now seeing thanks to "privacy concerns".

How Do I Get These Rankings Into My GA?

Different people have come up with different ways to get rankings directly into GA. One tactic is to create a custom profile using directions from this post by Chris Abernethy. This strategy works fairly well, but requires a lot of setup and requires you to be able to create another profile on your account. It also requires many steps and custom filters to clean the data.

Mike and I decided that a custom variable would be a better way to go. In order to make this strategy work, you need to be able to do the following (or know someone who can):

1) Insert the Javascript custom variable that I will provide you below into your section of your website below your normal GA code;

2) Insert a parameter into your <body> tag;

3) Be able to slice/dice your data in Analytics; and

4) Use some Excel wizardry to present the data.

The Code

Here's the code that you need to use to send the data from your site into GA. Put this code in the section of your site, directly under your normal GA code:

Get the code here

Now you need to put this code into the <body> tag of your site. Yes, directly within the body tag. This code:

onLoad="rankingsPush();

Your <body> tag will end up looking something like this:

<body onLoad="rankingsPush();">

Now sit back and let the data collect!

Where Do I Find This Data?

You find the data that is collecting under your Custom Variables tab in GA. I'll show you some screenshots. Click on Visitors > Demographics > Custom Variables, like so:

Custom Variables Location in GA

Then you'll see this screen:

Click Through 

Click through that and make your Secondary Dimension "Keywords". Boom! You get rankings and keywords!

What Can We Do With This Data?

Now we've got the rankings of the keywords driving traffic (which is what we really care about, right?). Data is worthless without applications, so let's come up with a few. Endless possibilities exist for slicing and dicing the data.

International Rankings

One cool thing that I did was match up the keywords and their positions with the country from which the visit came. You get the average ranking of the keyword driving traffic (which you also get in Webmaster Tools), but now you can break this down by country! Like so:

We could guess at what the (not provided) keywords are

We may also be able to guess at what the keywords coming up as (not provided) are now. As you can see in the screenshot below, I know that my visits from (not provided) are ranking #1 and #2. Based off of this, I can narrow it down to only my keywords ranking #1 and #2. If I do this for the data set I am working off of, I get these keywords:

Now that I've narrowed this down, I can take the landing pages for these rankings (set secondary dimension to "Landing Page"):

And I can see the landing page for my (not provided) keywords (Traffic > Sources > Search > Organic):

So, we can guess that most of the (not provided) keywords probably have something to with my name, since the majority went to my homepage where my name ranks #1 or #2.

*note* I am sure that someone with some mad Excel skills could automate this. If someone wants to take a crack at it, feel free and I'll link to it.

*edit* I need to give a shout out to Mike Pantoliano's post from last September where he details a very similar process. He also has some great applications in that post.

What other applications can you think of? How could we make this data sing even more?

I welcome your comments below!

Back to Top
John Doherty

John Doherty is the founder of GetCredo.com, where businesses can find the right marketing agency or consultant to work with. He is a search marketing industry veteran with deep experience across startups and enterprise websites with a penchant for very large and complicated sites. He lives in Denver with his wife Courtney and their very large black labrador Butterbean.

With Moz Pro, you have the tools you need to get SEO right — all in one place.

Read Next

13 Best AI Automation Tools to Increase Productivity & Efficiency

13 Best AI Automation Tools to Increase Productivity & Efficiency

Nov 25, 2024
Directional Reporting in GA4 — Whiteboard Friday

Directional Reporting in GA4 — Whiteboard Friday

Aug 02, 2024
UTM Tagging for Google Business Profile — Whiteboard Friday

UTM Tagging for Google Business Profile — Whiteboard Friday

Jun 21, 2024

Comments

Please keep your comments TAGFEE by following the community etiquette

Comments are closed. Got a burning question? Head to our Q&A section to start a new conversation.