It's been two years now since Google announced that they'd be gradually withholding the search terms from referer
headers, as secure (SSL) search was rolled out. This has meant that the keyword report in Analytics shows (not provided) for most visitors.
In our own Analytics reports, (not provided) keywords now make up 82% of all organic visitors.
For paid traffic (coming through AdWords) the keywords are still "provided," which is very helpful, but also very expensive.
And of course there's also the Search Queries report in Webmaster Tools. This is also useful, but it's still a disappointing loss of information compared to what we used to have (even if I personally think Google was probably right to go ahead with it).
The ved parameter to the rescue
Back in May, Tim Resnik wrote about patterns he'd spotted in Google's ved parameter. It turns out that ved codes contain rather useful information about the link that was clicked on in the search engine results page. And as Tim pointed out, this goes some way in replacing what was lost (or rather, killed off) by Google taking away the keyword data.
Three months later, Benjamin Schulz worked out that ved codes are actually encoded in Protocol Buffers (or "Protobuf"). So, as they're not actually encrypted, it's not too hard to unencode them (plus we don't have to feel too guilty about it!).
Google has even released open-source compilers (in several different languages), which you can use to decode ved codes yourself. However these compilers are probably a bit over-the-top for what online marketers need (and probably a bit hard to put into practice).
We've written up a guide to decoding and interpreting ved codes—as well as filling in some of the unanswered questions (such as what parameter 1
means). And we've also written a JavaScript function for decoding veds, which—as I want to explain—is essential if you want to incorporate this information into your own Analytics reports.
This article is an actionable guide to getting information out of these ved codes, and incorporating it into Analytics.
What is a ved code anyway?
I don't want to repeat too much what has already been written about in other posts, but it's a good idea to summarise what veds are, what's inside them, and how you can access them.
When you click on any of the links in Google's search results, the URL (address) of the link contains a "ved" parameter.
This "ved" code contains information about the link that you clicked on, and when a user comes to your website through Google's search results, the ved code is (usually) passed to you in the referer
HTTP header.
What's inside a ved code?
A ved code contains up to five separate parameters, which each tell you something about the link that was clicked on:
Link index (parameter 1)
All the links on the SERP have a numerical index, which gets passed in the ved code.
It only gives you a very rough idea of where the link was in the page (without knowing more about what was on the page), so it's the least useful of the five parameters inside the ved.
However, it is rather useful when it's for a ved code coming from an adword, simply because there's no other information about the position.
Although the link index only gives a rough idea of the position of the adword, there are two concrete things you can take from it:
- If it's about 45—65 or less (shopping results could go up to 85), then it means the adword was in the main column above the organic results
- If it's about 170 or over, then it means the adword was in the right-hand column or at the bottom of the page
Link type (parameter 2)
This parameter is a number which corresponds to the type of link that was clicked on.
The most common value is 22
, which corresponds to a normal (universal) search result.
Other common values (and their meanings) are:
Type of link | Value |
---|---|
normal (universal) search result | 22 |
sitelink | 2060 |
one-line sitelink | 338 |
image result (thumbnail) in universal search | 245 |
news result | 297 |
adword (i.e. sponsored search result) | 1617 |
See the complete list, for other (less common) values.
We've actually found well over a hundred distinct values, so this is a small fraction of them! Most of them, though, are very unlikely to appear in referer
URLs (bear in mind that these are Google's parameters; they weren't really meant for us).
You'll no doubt have noticed that there are lots of gaps in the values. I don't really know if this is because a lot have been retired, or if Google has left space for future link types (probably a bit of both, but more of the latter). For example, our reports show the link type 703
, but we haven't worked out what it means yet. It seems like it's some sort of universal search result just for mobile devices. If you see 703
or other codes in your reports, and you have an idea what they mean—write a comment below, or submit a pull request.
Start result position (parameter 7)
This parameter is the cumulative result position of the first result on the page. On page 2 it will be 10, on page 3 it will be 20, and so on.
It's better to think of this as the page number of results (after subtracting 1, and multiplying by 10)—because it's quite a long time ago now that there were always 10 results on every page. Anyhow, you'll need to interpret it in conjunction with parameter 6.
Result position (parameter 6)
This is very similar to the cd
parameter, but there are a few important differences:
cd
is counted from 1 (and upwards), whereas the ved result position is counted from 0.- On page 2 of the results,
cd
keeps on counting (i.e. 11, 12, 13…), but the ved result position is reset to 0. - Sometimes the
cd
parameter is not passed (e.g. for image thumbnails). In these cases, though, the ved result position does seem to get passed.
The ved result position is the more reliable of the two. If, for example, the cd
parameter is 11—you wouldn't know if this is the 11th result on page 1, or the first result on page 2. With the ved result position, you can distinguish the two.
Sub-result position (parameter 5)
This parameter is like the result position (parameter 6), except it tells you the position in a list of sub-results, such as breadcrumbs, or one-page sitelinks.
How to decode ved codes and pull the information into Analytics
To import the ved into Analytics, you'll need to include some Javascript to decode it (and send it to the Analytics servers).
To do this, you can modify your Analytics JavaScript "snippet" as follows:
1. Include the ved-decode and base64 libraries
You need to include these libraries in your HTML, somewhere before your Analytics snippet.
The ved-decode library is needed to decode the ved and extract the information we want.
The base64 library is needed for Internet Explorer users, because they won't have a native Base64 decoder available in their browser.
Each of the two libraries is licensed under a permissive open-source licence (MIT / Apache v2.0)—which lets you use it in any kind of project.
<!-- Include both these scripts or copy them into your main JavaScript file --> <!--[if lt IE 10]> <script type="text/javascript" src="https://veddecode.opensource.dpo.org.uk/js/base64-1.0.min.js"></script> <![endif]--> <script type="text/javascript" src="https://veddecode.opensource.dpo.org.uk/js/ved_analytics-1.0.min.js"></script>
2. Send the ved data to Analytics
How you do this depends on whether you're using the old Analytics (ga.js
) code, or the new <a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/">Universal Analytics</a> (<code>analytics.js) code:
If you're using Analytics (ga.js
)
Add this JavaScript code just before the call to _gaq.push(['_trackPageview'])
—
// The custom variable code needs to go *before* you record the pageview // (i.e. the call to _trackPageview) (function(w) { var customVars = [ { slot: 1, name: 'Google link index', v: 'linkIndex' }, { slot: 2, name: 'Google link type', v: 'linkType' }, { slot: 3, name: 'Google result position', v: 'resultPosition' }, { slot: 4, name: 'Google sub-result position', v: 'subResultPosition' }, { slot: 5, name: 'Google page', v: 'page' } ]; if (w._gaq && w.VedDecode && w.VedDecode.ved) { for (var i = 0, val; i < customVars.length; ++i) { val = w.VedDecode[customVars[i].v]; w._gaq.push([ '_setCustomVar', customVars[i].slot, customVars[i].name, val ? val + '' : '(not set)', 2 // session scope ]); } } })(window);
If you're using Universal Analytics (analytics.js
)
For Universal Analytics you need to set up custom dimensions corresponding to the five parameters:
Custom dimension name | Scope |
---|---|
Google link index | Session |
Google link type | Session |
Google result position | Session |
Google sub-result position | Session |
Google page | Session |
(These are suggested names, of course—you can call them whatever you like.)
Then add this JavaScript code just before the call to ga('send', 'pageview')
:
// The custom variable code needs to go *before* recording the pageview (function(w) { if (w.ga && w.VedDecode && w.VedDecode.ved) { // Send pageview with custom dimension data ga('set', { dimension1: getVedValue('linkIndex'), dimension2: getVedValue('linkType'), dimension3: getVedValue('resultPosition'), dimension4: getVedValue('subResultPosition'), dimension5: getVedValue('page') }); } function getVedValue(key) { var ret = w.VedDecode[key]; return ret ? ret + '' : '(not set)'; } })(window);
Make sure that the index generated for each dimension in your control panel corresponds to the dimension number in the JavaScript code.
For example, if the generated index for the Google link index dimension is 7
, then you need to refer to it as <code>dimension7 in the code.
Using the data
After a short while, the ved data should show up in your reports!
How you then use the data is up to you.
Clearly, though, it's going to be useful for optimizing different routes to your site, and looking at how different routes affect your conversion rates.
Personally, I think it's very interesting—for AdWords customers—to see how adword position (i.e. link index) affects conversion rates. It's very frustrating only having daily averages to work with, because you can't see (in the standard reports) how much your adword position varies during the day.
Please let us know what you do with the data in the comments below.
But what if no referer header gets passed?
This is important, because if there's no referer
header, then there's no ved parameter.
The referer
won't get passed in some cases:
If your site isn't secured by HTTPS
If your site uses HTTP, or it uses HTTP for some pages (in particular, any landing pages), then the referer
header may not get passed. Sometimes—even if a user is using secure (HTTPS) search—Google redirects them through a (non-secure) intermediate <em style="line-height: 1.45em;">HTTP</em> click-tracking page. When this happens, you'll get the <code style="line-height: 1.45em;">referer (and the ved parameter).
However, if Google passes them through a secure (HTTPS) click-tracking page, then you won't get the referer
(or the ved parameter) unless your site is also using HTTPS.
In conclusion—if you want to be sure of getting the ved parameter for as many users as possible—use HTTPS for your site. (Of course this isn't the only reason to use HTTPS!)
If the user is on a mobile device
For mobile devices, Google has started to use hyperlink auditing—which should have been called "click tracking", and is better known as the "ping" attribute—instead of redirects through a click-tracking page. Hyperlink auditing isn't as reliable as a redirect, though, which is why:
- Google only use it for mobile devices
- all paid results (e.g. adwords) still go through traditional redirects
According to Google, the main motivation for using the ping attribute (only) on mobile devices, is to improve speed—and I'm inclined to believe them. But it probably also helps that:
- mobile users are probably less likely to turn hyperlink auditing off (or know how, or know what it is)
- mobile devices run modern browsers, which support hyperlink auditing
However—you might ask—if mobile devices don't go through a redirect, and my site is using HTTPS, shouldn't I get the referer
anyway?
Yes, that's right, you should get the referer
!
But sadly, Google has specifically disabled it.
What Google do, if they use hyperlink auditing, is to set the meta referrer element to origin
:
<meta name="referrer" content="origin">
This instructs the user's browser to include the document's origin in the referer
header rather than the full URL of the document. So the <code>referer will just state (something like) <a href="https://www.google.co.uk/">https://www.google.co.uk/</a>
.
Before you think, "How evil!"—there's a good reason for this. If they didn't do this, then the search terms would also appear in the referer
, and Google has committed to turning this off for privacy reasons.
So, mobile devices are another kettle of fish, and ved code analysis won't work most of the time. But for most sites, mobile devices will still be in the minority, and things change quickly anyway. (For example, if there was a new anti-privacy law requiring hyperlink auditing to be off by default, that would certainly be the death of it.)
HI David,
Thanks for connecting the missing dots by providing ways to track ved in GA, however, I have two questions, which are as follows:
1) HTTP requests will not pass the headers, that means, majority of websites cant use this tracking. Can I conclude this?
2) "Not Provided" in Google Analytics is the data about "KEYWORD", which is still unavailable after this tracking. I know ved parameter can give you some info about what type of click it was(image, blog, sitelink), but still, main information is not available. Should I bother my developer for this tracking still?
Salik
Hi Salik, those are good questions.
1. You can still get ved information with an HTTP site, but you'll get much more if you use HTTPS.
If Google redirects someone through an HTTPS click-tracking page, then you won't get any referer, because browsers never pass the referer when going from an HTTPS page to an HTTP page.
However, if Google redirects through an HTTP click-tracking page, then you will get the referer. All paid traffic, and some organic traffic, goes through this route.
If Google turns on hyperlink auditing (for any particular visitor), you'll get a partial referer (but no ved parameter). They currently only do this for mobile (tablet / phone) and Chrome users. There's nothing you can do about this I'm afraid, but for us it makes up a minority of our traffic (at the moment).
For example, we found that for one of our non-secure (HTTP) sites:
Desktop visitors
Mobile visitors
As with desktops, all paid traffic gets a complete referer passed.
So there's quite a lot of traffic with no referer. This is not necessarily because they came from an HTTPS redirect page (users can turn off the referer in their browser settings)—but most of it will be. So it's worth implementing HTTPS on your sites if you can.
2. All indications are that Google has turned off the search terms for good. There's nothing you can do to get this information back, so if you want to build up the same kind of picture that you were getting before, you're forced to look for other sources of information.
It also seems to me that, if anything, Google's search results are becoming ever richer and more complex (think image, news, shopping, blog, patent, recipe results / knowledge graph / etc.). The ved information is a way of tapping into which type of result your users came from.
Whether it's worth implementing ved tracking is your decision, but in my opinion it's worth it because:
Hi David,
Thanks for the above explanations, your reply initself can be a blog :)
I guess the random usage of HTTPS/HTTP click-tracking page is because Google is still giving some Organic Keyword data in GA. Once, Google start blocking every organic Keyword data, we can presume that Google has started routing every click through HTTPS click tracking page and thus, HTTP sites will have no choice other than switching to HTTPS in order to decode ved parameter.
Anyways, thanks for your detailed explanation.
Salik
Personally I think that HTTPS will be a quality ranking factor in itself at some stage, in the same way that Google prefer fast-loading sites. It results in a better user experience.
Plus there are many other good reasons to switch to HTTPS.
Thanks for great post. it is numerical based concept and frankly i don't know before. I read again and again. thanks for share.
Not Provided in Google Analytic is the data about "KEYWORD", which is still unavailable after this tracking. I know ved parameter can give you some info about what type of click it
I read each paragraph twice to understand ved code and its numerical based concept, great stuff.. by the way, I just wonder what if ved related question asked in the Google Analytics Individual exam?! :-P because most of the search marketing folks are unaware of ved parameter. Thanks for the fruitful post david..
I don't think it will be in the exam because Google haven't ever revealed (publicly) how the ved parameter was encoded.
David, this is a wonderful post -- one of the best things about being an SEO is the fact that we learn something new every day. Today, it's the Ved Parameter!
One important application -- that I presume Google is using -- of start-result position (parameter 7) and result-position (parameter 6) is that perhaps we can calculate SERP click-through rates very accurately now? (See a recent, great Moz post by Andrew Martineau on a related topic here: moz.com/blog/mission-imposserpble-2-user-intent-click-through-rates).
With ved parameters, it would seem logical that we can now see which exact click in the ever-changing SERPs brought a given person to a website. Perhaps the value to marketers is that they can use this data to compare CTRs of their appearances in, say, Google News, Google Image Search, the Knowledge Graph, and a lot more. A basic example: If my website appears in Google SERPs in those three above areas but Google News is clicked a lot more than the other two, then perhaps I should adapt my strategy accordingly.
Would love to hear your thoughts!
Thanks Samuel
With click-through rates, I think it's a matter of building up a better and better picture of what's going on, without having the actual raw data to hand (for organic results, anyway).
And I think the ved information adds to that picture, especially in terms of what kind of link (e.g. image / news result / knowledge graph, etc.) people use to get to your site.
When you put it all the information together that you've got at hand (the ved data, landing page, browser type, the country-specific version of Google used, and so on), you can build up a good idea of what any particular user was searching for, and what link they clicked on.
Thanks for the insightful reply!
My thoughts exactly. I have some local clients who get bounced around from the carousel, to a standard seven pack, and then back to a standard SERP. Knowing how the shifting SERPs affect traffic will be helpful for explaining traffic variations to clients.
Highly useful technical stuff here. I didn't know anything about Google's Ved Parameter until now. Thanks, David.
I am going to try and implement this. For me, the best information this will provide is the site link the user clicks under the organic search result. Then, I can follow them through the conversion path from search result to transaction and differentiate the intent that each link attracts.
How should I validate these parameter's values? Please share a method of testing.
In theory, Google could add new parameters and new values, so whatever they put in the ved code is valid by definition. But we should validate whether the JavaScript code is decoding correctly. The best thing is if you could share an example ved code. Is that possible?
What could be the reason for getting 6 parameters and values?
Maybe Google have added a sixth parameter? It's certainly possible, and the format of the ved parameter certainly makes it possible. What were the six parameters you're getting? Could you give me an example ved code?
Hi Guys,
Thanks for the solution. I have borrowed the code and updated it and rewritten it in python for the newer variations of ved format. Take a look if u guys are interested.
https://github.com/PrashanthVenkat/Google-VED-decoder/issues/1
Hi David -- I am implementing this on one of my client's sites. I have it all set up in the staging environment, ready to push live. Is there a way to test this in the staging environment? Thanks!
After doing all the given steps where can I check the decrypted data in Google Analytics
Hey David,
Could you please confirm that the scripts are still working? I'm having troubles receiving the window.referrer data.
Many thanks
Tiago
I only know few of what a Ved Code is and am so very keen in learning this one. Can you please elaborate it more detailed so that for me to catched it up? Thanks David.
You can read more details in:
A new era of Digital marketing arising, More then 90% fact was unknown for me. Thanks for the valuable information.
I was not aware that Through a small script we can set ved variable in Google Analytics. Really Amazing.
Really valuable post. 98% of unknown facts.
Really helpful for SEO professionals like me.
Again the same comment "Known is a drop, and unknown is an ocean"
Thanks a lot for the post, Thank you David
Really happy when we new facts and information are shared by Moz Family Members.... hats off....
Brahmadas
We are surely "dwarfs standing on the shoulders of giants."
Great technical stuff here! I've seen the Ved information around but this posts shines light on what the data means! Thanks for sharing
So happy this post got promoted to the main blog! I had forgotten about it, and now it is on my todo list to play around with today.
Great post, it's amazing how quickly things change over time and the power Google has on digital marketing. I've seen some research showing that the latest generation are much less worried about privacy. So maybe we've hit the peak of privacy controls. I'm a fan of privacy controls but I often feel concerned that they tend to hit 'white hat' marketing rather than the truly nasty things such as spyware, viruses and malicious android apps (which Google could do something about).
Yes, Google certainly have too much power.
will your js work with the Google G.A.S (Google Analytics on Steroids) github project?
Hi Ainsley,
Yes it should work fine—GAS implements the same API as Analytics.
Just replace the _gaq variable with _gas, and make sure you paste the ved tracking code before your call to _gas.push(['_trackPageview']);
Of course, you also need to make sure you have custom variable slots available, and that you don't clash with another custom variable.
In the new Universal Analytics (analytics.js), you can define up to 20 custom dimensions, which is a big improvement on the 5 available slots in the classic version of Analytics (ga.js).
Hi David, Thanks for such a nice information. My query regarding QFj code in ved parameter, I think it will show that the result is from organic search and not that keyword in search query. I want to see those keywords from organic search, which is "not provided" in analytics. Please suggest.
Will this code work if I am using "html file" for analytics verification?
Yes the Qfj in the ved code means that the user came from an organic search result, but you can't rely on splitting apart the ved code in that way—you should decode it using a JavaScript function.
The ved parameter doesn't contain the search terms (keywords) that the user entered—Google has committed to turning this information off (in the referer header, at least). In my opinion, the two easiest ways of looking at keyword data now is:
The ved tracking code will work if you use static HTML files, but you'll have to make sure that you've included the Analytics JavaScript snippet on every page (particularly your landing pages).
Hey David,
I am always saw the Ved Parameter in link when i was copied the link location, but don't know that how its work and whats inside this parameter, but this post giving me all the information.Now i am understand that what is Ved Parameter actually and how its working? Thank you so much David for this informative post.
Apologies if this has already been said, but it's worth mentioning again that Tim Resnik found the article on SEOmanontroppo that gave rise to their interest in ved param (https://www.seomanontroppo.com/analitica-en-google-news-otras-zarandajas/). Just want to make sure credit goes where credit is due!
Hi Jon,
Yes I knew about that SEOmanontroppo article, but it was referenced by Tim Resnik's article—which I referenced myself—so I hoped that would have been OK!