Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode google gclids

Tags:

Now, I realise the initial response to this is likely to be "you can't" or "use analytics", but I'll continue in the hope that someone has more insight than that.

Google adwords with "autotagging" appends a "gclid" (presumably "google click id") to link that sends you to the advertised site. It appears in the web log since it's a query parameter, and it's used by analytics to tie that visit to the ad/campaign.

What I would like to do is to extract any useful information from the gclid in order to do our own analysis on our traffic. The reasons for this are:

  • Stats are imperfect, but if we are collating them, we know exactly what assumptions we have made, and how they were calculated.
  • We can tie the data to the rest of our data and produce far more accurate stats wrt conversion rate.
  • We don't have to rely on javascript for conversions.

Now it is clear that the gclid is base64 encoded (or some close variant), and some parts of it vary more than others. Beyond that, I haven't been able to determine what any of it relates to.

Does anybody have any insight into how I might approach decoding this, or has anybody already related gclids back to compaigns or even accounts?

I have spoken to a couple of people at google, and despite their "don't be evil" motto, they were completely unwilling to discuss the possibility of divulging this information, even under an NDA. It seems they like the monopoly they have over our web stats.

like image 716
Draemon Avatar asked Dec 13 '08 22:12

Draemon


People also ask

Can Gclid be decoded?

We've recently found out how to decode the gclid parameter (in Google Adwords). It turns out that this parameter is not actually encrypted—anyone can decode it quite easily.

How do I get Gclids from Google Ads?

How do you enable GCLID tracking? Setting up GCLID is pretty easy. First, access Google Ads, click "Settings," > "Account settings," > "Auto-tagging." From there, select "Tag the URL that people click through from my ad," and save your changes. Then, make sure your Google Ads and Analytics accounts are linked.

What does Gclid mean in a URL?

Google Click ID (GCLID) is a parameter passed in the URL with ad clicks, to identify the campaign and other attributes of the click associated with the ad for ad tracking and campaign attribution. In Google Ads, this is enabled by turning on the auto-tagging setting.

How do I find my Gclid?

In Chrome Developer Tools, under the Networks tab, click on the collect request in the left pane. In the Headers pane on the right, under the Query String Parameters section, look for the dl parameter in the collect request. You should see gclid=TeSter-123 .


2 Answers

By far the easiest solution is to manually tag your links with Google Analytics campaign tracking parameters (utm_source, utm_campaign, utm_medium, etc.) and then pull out that data.

The gclid is dependent on more than just the adwords account/campaign/etc. If you click on the same adwords ad twice, it could give you different gclids, because there's all sorts of session and cost data associated with that particular click as well.

Gclid is probably not 100% random, true, but I'd be very surprised and concerned if it were possible to extract all your Adwords data from that number. That would be a HUGE security flaw (i.e. an arbitrary user could view your Adwords data). More likely, a pseudo-random gclid is generated with every impression, and if that ad is clicked on, the gclid is logged in Adwords (otherwise it's thrown out). Analytics then uses that number to reconcile the data with Adwords after the fact. Other than that, there's no intrinsic value in the gclid number itself.

In regards to your last point, attempting to crack or reverse-engineer this information is explicitly forbidden in both the Google Analytics and Google Adwords Terms of Service, and is grounds for a permanent ban. Additionally, the TOS that you agreed to when signing up for these services says that it is not your data to use in any way you feel like. Google is providing a free service, so there are strings attached. If you don't like not having complete control over your data, then there are plenty of other solutions out there. However, you will pay a premium for that kind of control.

Google makes nearly all their money from selling ads. Adwords is their biggest money-making product. They're not going to give you confidential information about how it works. They don't know who you are, or what you're going to do with that information. It doesn't matter if you sign an NDA and they have legal recourse to sue you; if you give away that information to a competitor, your life isn't worth enough to pay back the money you will have lost them.

Sorry to break it to you, but "Don't be Evil" or not, Google is a business, not a charity. They didn't become one of the most successful companies in the world by giving away their search algorithm to the first guy who asked for it.

like image 149
Chris Avatar answered Sep 19 '22 17:09

Chris


The gclid parameter is encoded in Protocol Buffers, and then in a variant of Base64.

See this guide to decoding the gclid and interpreting it, including an (Apache-licensed) PHP function you can use.

There are basically 3 parameters encoded inside it, one of which is a timestamp. The other 2 as yet are not known.

As far as understanding what these other parameters mean—it may be helpful to compare it to the ei parameter, which is encoded in an extremely similar way (basically Protocol Buffers with the keys stripped out). The ei parameter also has a timestamp, with what seem to be microseconds, and 2 other integers.

like image 25
andre Avatar answered Sep 17 '22 17:09

andre