Getting your affiliate sales into Google Analytics

Posted by in Analytics & Affiliate on Feb 21, 2012

During my career as an affiliate publisher I’ve tried and tested many ways to track and analyze my affiliate sales, but I never found the perfect way. Until I discovered there was a way to get my affiliate sales into Google Analytics. I had to take quite a detour to make it work, but it turned out to be totally worth it! I’ve been using this technique for over 2 years now, but I recently discovered nobody is using this technique yet… WOW!

A little research…

Last week I conducted a small research (n = 22) amongst (Dutch) affiliate publishers and the results were shocking! From those 22 affiliate publishers, not one affiliate publisher imports their affiliate sales into Google Analytics, even though 77% said they see advantages of making affiliate sales visible inside Google Analytics.


The reason why affiliate publishers aren’t using this potential was easy to identify: 91% of the respondents had no idea how to set it up or even thought it was technically impossible.

I also asked them what kind of system they’re mainly using to do their analysis in. As expected, most affiliates use the stats systems of the networks (77%). 18% uses a custom-made tool, and only 9% uses 3rd party tools such as Proser 202. Only 1 affiliate appeared to be really happy about his current way of analyzing, he gave his stats-system a 5 out of 5. Most respondents (9 out of 22) gave their stats-system a 3 out of 5, making clear they’re not as happy about it as they should be.

Especially when I added an open question about the benefits of having their affiliate sales visible inside Google Analytics, it became clear to me. Respondents knew exactly what would be possible (e.g. see exactly how each traffic source/URL/keywords etc is converting / see the whole funnel, etc etc), but they simply don’t know how to set it up.

Until today.

I’ll be sharing my secret with you, so you can also make your affiliate sales visible into Google Analytics!

Possibilities

Assuming you’re an affiliate (or maybe even a stats-junkie like me?), I don’t have to tell you what the possibilities of Google Analytics are. Simply put you can run all the reports you would normally run… and have your affiliate sales included in the reports as well!

It’s simply impossible to list all the possibilities, but I’ll just name a few examples:

  • Detailed stats on visitor sources: how much is each traffic source worth? Which keyword converts best?
  • View and compare trends across your affiliate sales across any length of time. At what times/days are certain products selling best?
  • Visualize the complete funnel. See exactly which path users take before they make the actual sale.
  • Test multiple designs by giving each of them a unique User Defined variable. See exactly which designs generates the most money (instead of optimizing on CTR)!
  • Affiliate conversion rates per OS, browser, mobile and connection. Makes it easy to identify when a merchant isn’t compatible with a specific browser or OS, or which campaign is converting best on (specific) mobile phones.

Like I said, these are just some examples from the top of my mind, but it should make it clear to you that you can optimize your websites to a whole new level!

In case you’re more of a visual-kinda guy, here are some screenshots of reports that include affiliate sales.

How to connect your affiliate sales with GA?

Luckily for you, you don’t have to re-invent the system yourself. I’m sharing my custom-made code with you that will make sure your affiliate sales will be imported into Google Analytics as well. Do you want to know my “little secret” how it works? We’ll, explain it to you:

When a visitor clicks on an affiliate link, the following will happen:

  • An unique ID will be assigned to that click-out (e.g. “RGXPxap2wlFOeSbKwHFU)
  • The Unique ID will be included in the affiliate link (e.g. http://xxx.hop.clickbank.net/?tid=RGXPxap2wlFOeSbKwHFU)
  • The content of the Google Analytics cookies and the unique ID will be saved in a database.

As soon as there is a sale or lead at one of the affiliate programs, Affiliate2Analytics will match the unique identifier of that sale with all click-outs so it knows exactly what the content of the Google Analytics cookies of the original user were. At this point, Affiliate2Analytics will automatically send an E-Commerce Transaction to your Google Analytics account as if it were the original user.

Pretty neat eh?

Feel free to download this tool yourself and give it a go!

 P.S. I’d be happy to hear some feature requests and ideas in the comments below!

3 Comments

  1. Mar 1, 2012

    Any idea on how to use this with Commission Junction? I have been trying to get a vendor to put my conversion tracking script on their thank you page, but they’re balking even though I’m one of their top affiliates.

    • Mar 2, 2012

      Hi Jordan,

      I’m currently not (actively) using Commission Junction, so I’m not sure whether they support trackback URL’s. I know they have an API, but it needs quite a bit of custom coding to make that work.. If there is enough demand for CJ-support, I might implement it.

  2. Jun 14, 2012

    Great script. I hacked it a bit and I think it may help those who (like most) have networks who do not have the ability to append a subid from the offer page into a link that is fired upon conversion. Most networks, however, allow you to send them a javascript pixel. To me, it makes more sense to save the A2ASUBID in a cookie rather than having it pass through the offer page and all the other steps required to get to the conversion page.

    What I did is in clickout.php, right before the clickout is inserted into the DB, I set a cookie with the A2ASUBID info in it like so:


    session_start();
    setcookie('A2AID', $subid, time()+60*60*24*30*3);

    then , in conversions.php, make the subid config like so:


    $subid = $_COOKIE['A2AID'];

    Also, since my network doesn’t have the ability to insert the order id into the pixel, I achieved this by inserting some code into the pixel which simply pulls it out manually from the url. The pixel to give to your network should look something like this:

    function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if(results == null)
    return "";
    else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
    }
    var track = new Image();
    track.src="http://yoursite.com/conversions.php?&order_id=" + getParameterByName('order_id');

    in getParameterByName(‘order_id’), you can simply replace ‘order_id’ with whatever parameter name your network uses. All you would need is to see a sample of what the url looks like when a conversion happens, and replace the order_id part with any unique ID that they generate. This should allow this tool to work with most networks.

    note: i found that in the pixel if you use http://www.yoursite.com instead of http://yoursite.com, it wont work. make sure you dont put “www.” in the url

    I’ve tested this and it’s successfully creating e-commerce transactions in GA, however, maybe you will see some consequences of doing it this way?? Let me know what you think.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>