How to get AdWords data about your individual users

AdWords reporting and Google Analytics are incredibly powerful tools, but they tend to focus on aggregates. You'll never be able to get the specific campaign/adgroup/ad/keyword that a certain user used to sign up. If your leads (say, newsletter signups) are very expensive, this can be unacceptable -- you need to know everything about how you got that specific lead.

Luckily, there is a way!

We're going to capture the GCLID using a hidden field in your form(s), then use to get all of the information about the click that lead to the signup.

What is a GLICD?

GCLIDs are the lifeblood of adwords tracking. Each AdWords click is assigned a unique GCLID, which is automatically appended to the end of your destination URLs: All of the information regarding the click is associated to that ID. If you have the ID (and the day of the click, as we'll see), you can get that information out.

How to get the GCLID

It used to be that GCLIDs would be stored in the _utmz cookie, but with Universal Analytics, that is no longer the case. We'll have to implement a simple script to make sure we don't miss out on the cookie, independent of Google Analytics.
Our objectives:

  1. Add a hidden field on forms where we want to store the GCLID
  2. On every page, if a the URL ever has ?gclid=<something> set, we'll store that something in our own cookie.
  3. On every page, if there is a form with the hidden field, populate it with our cookie
Adding the hidden field to your form

In your HTML, immidiately before the </form> tag of your page, add:

<input type="hidden" name="gclid" value="" id="gclid" />  

Right now, it has no value. We will add some javascript to populate it.

Fetching the GCLID and populating the hidden field

Put this script on every page of your website (anywhere on the page is fine). It has no dependencies.

function getParameterByName(name) {  
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(;
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

function setCookie(cname, cvalue, exdays) {  
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires+ "; path=/";

function getCookie(cname) {  
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
    return "";

function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}

        setCookie('gclid_hold', getParameterByName('gclid'), 60);

    if(getCookie('gclid_hold') && document.getElementById("gclid")){
        var gclid_input = document.getElementById("gclid");
        gclid_input.value = getCookie('gclid_hold');

This script is made of two parts:

  1. On every page, if a gclid is detected in the url, stuff it into a cookie called gclid_hold
  2. On every page, if a cookie named gclid_hold exists, put its value into the form field with id gclid

That's it.

If your form handler absorbs this new field correctly, you will start seeing GCLIDs in your signup reports.

Getting the AdWords data for that GCLID

First, sign up at (which is free, with no strings attached as far as I can tell), and link your adwords MCC that contains Navion. You will then be given a text box in which you can type SQL-like queries to get raw data from the API.

To get info about a GCLID, try this:

For your copy-pasting pleasure, here's the query in that screenshot:

select GclId, AdGroupId, CampaignId, CityCriteriaId, CriteriaParameters, ClickType  
where GclId="CjwKEAiAlvilBRC5ueCzkpXb4kgSJADxop1BJgoUprIpqBEBCDf1yZMQurqKlivXM8SoZ9BHRYjmqBoCMfXw_wcB"  
during 20150120,20150120  

This will give you all sorts of useful information about the click. Note that the CLICK_PERFORMANCE_REPORT is a special table where you can only request one day at a time. The format of the day is always YYYYMMDD,YYYYMMDD, where both dates are the same. You need to know the day that the click happened. You can remove the whole where clause if you want all the GCLIDs in that day. You can also add other fields to the select clause if you want other columns in the result (like city, etc) -- there is a help section on the right that lists everything available.

If you're curious, here's some more info about the all the report types available:

Happy querying!

PS: If you can't find a GCLID, it might be an invalid click. Read more about them here: