Google Analytics hack for TOUCH attribution of sales, leads and other conversion goals

Article written by Claudiu Murariu

In other words: Find out ALL the traffic sources that bring visitors to your website who eventually buy.

Imagine the following scenario: the customer first visited your website by clicking an ad, then visits your website from your newsletter and when he decides to buy he goes to Google, and searches for your site name. By default, Google Analytics considers the referrer of the sale the last source that brought the visitor to your website.

If your Google Analytics eCommerce report attributes many sales to your branding organic searches, the chances are you are loosing a lot of data about the performance of your web marketing efforts.

Understanding the impact of your marketing channels better will help you take better decisions in investing money and resources wisely. SeoMoz has a great article on how to go around it, but I prefer the following 3 step  wizard  you can use to find out ALL the referrers of your customers before they click the Confirm Order button:

Step 1: Save referrers

Add the following code just after the Google Analytics tracking code. This script will use the Google Analytics cookies to store the referrer of a visitor for each of his visits.

function createCookie(name,value,days) {
                if (days) {
                    var date = new Date();
                    var expires = "; expires="+date.toGMTString();
                else var expires = "";

                document.cookie = name+"="+value+expires+";domain="+window.location.hostname+"; path=/";

            function readCookie(name) {
                var nameEQ = name + "=";
                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,c.length);
                    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
                return null;

            function googleCookieReferrer()

                var feed=readCookie("__utmz");

                //if the utmcsr is not found, cancel
                if(feed.indexOf("utmcsr")==-1) return null;


                    //new version cookies

                        //old verion cookie

                        return feed[1];
                        return "";
                else return "";

           //read the google cookie, and extract the utmcsr parameter from utmz
           var referer=googleCookieReferrer();

       //if the google cookie was succesfully read, and utmcsr found
        if(referer!=null && referer!="") {

          //read our cookie, if it exists
                  //cookie data
                  var feed=readCookie("__rfrr");
                  //temp cookie string
                  var feed_temp=feed;
                  //this will hold the last referer in our cookie
                  var check="";

                      //split the data in our cookie.

                      //if its the first element -> string
                          //if multiple elements -> array ->get last

                      //if last element != referer write cookie, add new referer
                      if(check!=referer) createCookie("__rfrr",feed_temp+"|"+referer,1000);

             } // if no cookie found. Create, and populate
             else createCookie("__rfrr",referer,1000);

The above code can be adapted by your developers so you can get crazy with it. :)

Step 2: Save data

When the sale happens save the new referral cookie content to your database. You might want to link each customer to his referrers. Ask your programmers to do this operation. Most of the times it’s simply a walk in the park for them to do it.

You could send in the same time the cookie content to Google Analytics as an event but I find it very useful to have it stored on the database. You can use the information much easier in the future for targeting campaigns.

Step 3: Generate reports

Create your own referral reporting area. Here is how your reports could look like:


Just like the reports above, you will have a clear image of the impact of marketing channels on first click, middle click and last click purchases.

Ask you developers to offer you such a report in your website back-end area or simply tell them to send you periodical exports of the data and generate Excel spreadsheet reports. You can go even one step further, and import as well some visitor behavior data though the Google Analytics API to make better use of the reports. Excellent Analytics is a plugin that can help you with that. Start doing some segmentation and most likely you will strike gold.

With the hack in place, you should be able to have a clear image of your marketing channels impact on your website.

Google Analytics hack for TOUCH attribution of sales, leads and other conversion goals by

1.100.000+ email leads collected with

PadiAct helps you get more email leads. More and better.

  • Pingback: Are there any free tools for multi attribution conversion tracking? - Quora

  • barry mann

    Multi touch attribute is all the rage this year. Its like a lightbulb as gone off above the industry’s head that last click is not fit for purpose, and is a load of rubbish. First click is even worse. A whole load of companies (tagman, DC Storm, shomei) have sprung up in this space. Existing PPC management software vendors such as Acquisio are doing it as well. This hack is free, but tagman offers more attribution methods such as weighted click or decay curve (a click yesterday is worth more than one last week). Very fast moving. Also selective firing of tags. Watch this space.

  • Trent Blizzard

    Time to get excited if you are a Google Analytics User… Multi-channel tracking and funnels are coming soon!

    Read more and watch videos at:

    PS… am now using both padiact and paditrack… stellar, thanks.

    • Claudiu

      I am also looking forward to the Multi-channel reports. It’s about time they do something about it. :) From the look of it, the new reports seem to cover most of the issues related to multi-touch tracking.
      Thanks for the comment and your appreciations.