How to get AdWords data about your individual users - ASP TANMOY

Latest

Friday, 22 January 2016

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 https://awql.me 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: example-destination.com/foo/?gclid=CI-b8dup9cECFTMQ7AodTVwAYA). 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.

<script>  
function getParameterByName(name) {  
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
    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()}

r(function(){  
    if(getParameterByName('gclid')){
        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');
    }
})
</script>  


Source :altus.io

2 comments:

  1. Oh! This is great. I have been thinking of starting my own business but was wondering about the marketing and promotion of it. I forgot that there is SEO and Adwords Campaign Management now days that can make things easier. I am grateful to you for sharing this useful post. This way I can expand my business in the market.

    ReplyDelete