+ Reply to Thread
Results 1 to 10 of 10

 

Thread: Duplicate Commission Stopper - For mechants who use more than 1 network.

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts


    I have been asked about this a few times now so I thought I would post the code on here.

    These scripts will provide a very useful service to all merchants who use more than one Network as it will save them time and prevent them from upsetting affiliates by returning duplicate commissions across multiple networks – as only the last referring network will be triggered on checkout.

    How does it work ?

    Well its quite simple really most shopping carts have an overall template or a global include file (not to worry if yours does not) the code (available in asp. php and javascript (for those of you with html pages via mod re-write or what ever)) checks which Network the user came through and sets a cookie with that network as a reference if the user goes on to buy a product the cookie is looked up and only the referring networks tracking is used and our reference cookie is expired. If however the user goes off to compare more pricing and ends up back at our store via another affiliate site on a different network our reference cookie is overwritten with the new network and the process begins again. So far this works with affiliate window and affiliate future I am adding webgains and cj as we speak and will gladly add all the networks to it.

    I am posting these code sets to use freely and will help any merchants add it to their site. PM me if you would like help using them.

    If you do use any of the code sets and find them useful and do want to make a donation please feel free my paypal email address is payments@future-websites.com (AKA the wife’s ebay fund )

    I will attach the scripts soon in the mean time can any networks who have not been mentioned above (affiliate future, affiliate window, webgains and cj) pm me so that your merchants can benefit form these code sets.Basicly I just need to know if merchants can append their own querystring names and values to the end of their links. i.e aff=NetworkName


    DEMO:
    http://www.futurewebsite.co.uk/test.htm?aff=aw
    (cookie set to aw)

    http://www.futurewebsite.co.uk/cookies.php
    (see cookie set)

    http://www.futurewebsite.co.uk/testcheckout.php
    (test checkout)

    go round again using af instead of aw

    then again using anything other than af or aw

    then go back and use aw look at the cookie set (http://www.futurewebsite.co.uk/cookies.php) go back to test.htm and use af then look at the cookie set again to see it has been overwritten with af


    Thanks

    Adrian

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've got a few pointers to help you improve your script...

    Set the local cookie to expire as far in the future as possible. Some programs have cookie times longer than 30days and there is no downside to having this cookie length longer than the network cookie.

    You are deleting the cookie when a sale is made, why? One of the reasons for longer cookie times is to track multiple sales and your current code apears to break this.

    If no local cookie is set you should show tracking code for all networks. If your implementation is 100% reliable this shouldn't have any effect (as no network cookies would be active) but would mean the tracking would still work if the local cookie has been deleted (e.g. local cookie time to short) or hasn't been set (e.g. the user has javascript disabled or was deeplinked to a page the merchant hadn't thought of putting your code on). This does make it possible for sales to track on multiple networks, but only in cases where you local cookie has failed and its easier spot and correct a sale that tracked twice rather than one that was never logged at all.

    Hope this is of some use.

  3. #3
    graeme's Avatar
    Registered User

    Status
    Online
    Join Date
    Aug 2003
    Posts
    321
    Thanks
    2
    Thanked 20 Times in 16 Posts
    Also worth mentioning that if the Merchants order process is hosted on a different domain name then you won't be able to read the Local Cookie. It is easy enough to modify the script to set the cookie for all sub domain names so if the secure server was at secure.merchant.domain then it would be fine. But a way of moving or sending the local cookie data to the order system would be needed if the secure server is on a different domain all together. Such a method could be that the local cookie is read just before the visitor is redirected to the secure server and the data is passed via the query string.

    Graeme

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    EDITED TO INCLUDE Rich's Pointers (thanks Rich)

    Javascript version:

    Set the cookie (this part goes accross all your product pages in a .tpl file or global include)
    you can dump the lot in a single js include file and just add
    Code:
    <script type="text/JavaScript" language="JavaScript" src="/network.js"> </script>
    ** the above asumes you named your js file network.js and it sits in the same dir

    Code:
    <script language="javascript">
    function setCookie(name, value, expires, path, domain, secure) {
    var thisCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = thisCookie;
    }
    
    function PageQuery(q) {
    if(q.length > 1) this.q = q.substring(1, q.length);
    else this.q = null;
    this.keyValuePairs = new Array();
    if(q) {
    for(var i=0; i < this.q.split("&").length; i++) {
    this.keyValuePairs[i] = this.q.split("&")[i];
    }
    }
    this.getKeyValuePairs = function() { return this.keyValuePairs; }
    this.getValue = function(s) {
    for(var j=0; j < this.keyValuePairs.length; j++) {
    if(this.keyValuePairs[j].split("=")[0] == s)
    return this.keyValuePairs[j].split("=")[1];
    }
    return false;
    }
    this.getParameters = function() {
    var a = new Array(this.getLength());
    for(var j=0; j < this.keyValuePairs.length; j++) {
    a[j] = this.keyValuePairs[j].split("=")[0];
    }
    return a;
    }
    this.getLength = function() { return this.keyValuePairs.length; } 
    }
    function queryString(key){
    var page = new PageQuery(window.location.search); 
    return unescape(page.getValue(key)); 
    }
    function displayItem(key){
    if(queryString(key)=='false') 
    {
    // THE QUERYSTRING IS NOT AFF SO COOKIE NOT SET  //
    }else if(queryString(key) != 'af' && queryString(key) != 'aw'){
    // AFF DOES NOT = af or aw (OUR NETWORKS) NO COOKIE SET //
    }else{
    // QUERYSTRING DOES = af or aw OUR NETWORKS SO COOKIE SET //
    var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365)); // change last number for number of days you want the cookie to live.
    setCookie('network',queryString(key),expdate)
    }
    }
    if(window.location.search.substring(1) != ''){
    displayItem('aff')
    }
    </script>
    important parts of the code explained:

    displayItem('aff')

    aff is the substring (querystring) we are looking for i.e aff=VALUE

    Code:
    }else if(queryString(key) != 'af' && queryString(key) != 'aw'){
    this disregards anything that does not = the networks we are looking for i.e af (our code for affiliate future ) and aw (our code for affiliate window)

    to add other networks you would simply alter the above so lets say we have affiliate window, affiliate future and web gains ( have been into webgains and set aff=wg as you custom values to append your querystrings * ask webgains how this is done)

    our code will now look like this:

    Code:
    }else if(queryString(key) != 'af' && queryString(key) != 'aw' && queryString(key) != 'wg'){
    Now lets take a look at the code to trigger the correct network after checkout and destroy our local cookie.

    this code goes where your network code goes on the end of your checkout.

    we will be using our standard example of af and aw as above then show you how to modify it to include others.


    Code:
    <script language="javascript">
    
    function getcookie(cookiename) {
     var cookiestring=""+document.cookie;
     var index1=cookiestring.indexOf(cookiename);
     if (index1==-1 || cookiename=="") return ""; 
     var index2=cookiestring.indexOf(';',index1);
     if (index2==-1) index2=cookiestring.length; 
     return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
    }
    
    
    if(getcookie('network') == 'af'){
    
    // Affiliate FUTURE CODE GOES HERE !!!! ??? >> //
    
    }else if(getcookie('network') == 'aw'){
    
    // Affiliate WINDOW CODE GOES HERE !!!! ??? >> //
    
    }else{
    // NO COOKIE SO USER DID NOT COME FROM A NETWORK //
    // ALL NETWORKS CODE HERE INCASE WE MISSED //
    }
    // DONT KILL OUR COOKIE
    </script>
    <noscript>
    <!--// 
    Mod by Rich ALL networks here 
    //-->
    </noscript>
    As with the above example lets say we have added Webgains as aff=wg we would add

    Code:
    }else if(getcookie('network') == 'wg'){
    // WEBGAINS CODE HERE ?? >> //
    this would be placed under or above:
    Code:
    }else if(getcookie('network') == 'aw'){
    
    // Affiliate WINDOW CODE GOES HERE !!!! ??? >> //

    I have started with the javasctript one as it is the most difficult with asp and php it is far simpler to request querystrings, request cookies and set them. But the great advantage is it will work with html pages good news if you are ussing mod_rewrite for your SEO. Most of the functions used in the above code widley available on the net if you want to go it alone do a google "javascript FunctionName.


    Quick Note:
    Cookies can only be read by the domain that set them ** this will require extra programming to work if your check out is on your main site but your products are on a sub domain or vice versa. And will not work if the 2 are hosted on seprerate sites.

    Stay tuned for the ASP and PHP versions and a smarty one for your checkout pages (.tpl)

    You will of course be able to mix and match javascript & php & smarty PHP & ASP accross your products and end of checkout pages.

    I will help freely to install this soloution if anyone needs and you can drop some into the wifes ebay fund if you so wish.



    Enjoy.
    Last edited by futureweb; 02-12-05 at 06:28 PM.

  5. #5
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    Hi Chaps,

    graeme I was building up to that. I should have waited to post the 2 lots together.

    Rich yep agreed we can change the expirey very easily

    if javascript is disabled there are asp and php alternatives as I stated. And even if it was disabled it would only serve to trigger all the networks as before and a manual duplicate removal would have to be done just not as often and further more don't some of the networks use javascript includes to do their tracking ? if so their code would not fire either.

  6. #6
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're using javascript on the checkout page you would really want to also include all the tracking images within <noscript> tags to ensure they get shown to any users with javascript disabled.

    I thought the networks that use javascript tracking also use a standard image/callback as well for a backup, at least I hope they do as a lot of users have it disabled.

  7. #7
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    Yes I would have thought so most agreed on the noscritps just finishing up the other parts then we can all take a look and make it better I would think most merchants if not all will have either php asp or .net checkouts or perl / cgi or coldfusion for that matter and will use one of the server side snippets to fire the network once I have posted these there should be a mix and match soloution for most if not all.

  8. #8
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    ASP Code:

    Now lets look at the asp example we could use select case if we 3 + networks but we can look at that later.

    set our local cookie: (this would go in header.asp or alike)

    Code:
    <%
    function setCookie(Val)
    Response.Cookies("network")= Val
    Response.Cookies("network").Expires = Now() + 365
    End function
    
    aff = Request.QueryString("aff") 
    
    if aff = "aw" or aff = "af" then
    call setCookie(aff)
    end if
    %>
    the only bit of code we need to change if adding another like the example above we will use webgains aff=wg

    Code:
    if aff = "aw" or aff = "af" or aff = "wg" then
    We could also make a tracking img like the networks do and use that instead.

    now lets move on to the checkout page:

    Code:
    <%
    if request.cookies("network") = "aw" then
    %>
    <!--// Affiliate Window code here //-->
    <%
    elseif request.cookies("network") = "af" then
    %>
    <!--// Affiliate Future code here //-->
    <%
    else
    %>
    <!--// All Networks here in case we missed //-->
    <%
    end if
    %>
    and again we will use webgains as an example and add aff=wg

    Code:
    <%
    elseif request.cookies("network") = "wg" then
    %>
    <!--// Webgains code here //-->
    this can be placed under or above
    Code:
    <%
    elseif request.cookies("network") = "af" then
    %>
    <!--// Affiliate Future code here //-->
    Last edited by futureweb; 02-12-05 at 08:21 PM.

  9. #9
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    Now for the php

    this is the code to set our local cookie as with the asp version this wants to sit in a global inc file such as header.php

    Code:
    <?
    function MakeCookie($value){
    setcookie ("network", $value,time()+60*60*24*365);  
    }
    
    if($_GET['aff'] !=''){
    $aff = $_GET['aff'];
    
    switch ($aff) {
    case "af":
       MakeCookie('af');
       break;
    case "aw":
       MakeCookie('aw');
       break;
    }
    }
    ?>
    as before lets add webgains to it with aff=wg

    Code:
    case "wg":
       MakeCookie('wg');
       break;
    this can go under or above or indeed above the af section
    Code:
    case "aw":
       MakeCookie('aw');
       break;
    then again for the checkout side a simple if condition

    Code:
    <?
    
    $aff = $HTTP_COOKIE_VARS['network'];
      
      if($aff == 'af'){
    ?>
    <!--// AFFILIATE FUTURE CODE HERE //-->
    <?
    // WE COULD write it with php as well
    }elseif($aff == 'aw'){
    ?>
    <!--// AFFILIATE WINDOW CODE HERE //-->
    <?
    }else{
    ?>
    <!--// FIRE ALL IN CASE WE MISSED //-->
    <?
    }
    ?>
    and to add webgains aff=wg we would add


    Code:
    <?
    }elseif($aff == 'wg'){
    ?>
    <!--// AFFILIATE WINDOW CODE HERE //-->
    this would go under or above

    Code:
    <?
    // WE COULD write it with php as well
    }elseif($aff == 'aw'){
    ?>
    <!--// AFFILIATE WINDOW CODE HERE //-->
    there are lots of ways we can do this with asp and php these are just ideas off the top of my head which will do the trick and are easy to add new networks to. * Speak to your network and ask if you can add aff=Networkabv
    Last edited by futureweb; 02-12-05 at 08:21 PM.

  10. #10
    Registered User

    Status
    Offline
    Join Date
    Jul 2005
    Location
    North Devon
    Posts
    899
    Thanks
    13
    Thanked 21 Times in 21 Posts
    Now for smarty php code you can play this one of 3 ways

    1) smarty code:

    Code:
    {if $smarty.cookies.network eq "af"}
    <!--// 
    Affiliate future code here 
    You will need {litertal}around any javascript{/literal}
    //-->
    {elseif $smarty.cookies.network eq "aw"}
    <!--// Affiliate Window here //-->
    {else}
    <!--// all networks here in case we missed //-->
    {/if}
    again using our example webgains using aff=wg we would add

    Code:
    {elseif $smarty.cookies.network eq "wg"}
    <!--// Webgains code here //-->
    above or below
    Code:
    {elseif $smarty.cookies.network eq "aw"}
    <!--// Affiliate Window here //-->

    2) use the php above replacing <? with {php} and ?> with {/php}

    3) use the javascript Wrapped in {literal} <!--// javascript //--> {/literal}
    Last edited by futureweb; 02-12-05 at 08:20 PM.

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Tiscali Network and Broadband affiliates
    By KieronD in forum Affiliate Marketing Lounge
    Replies: 11
    Last Post: 23-12-05, 11:25 AM
  2. a4u Pub Meet - Brighton 20th July 2005
    By Matthew Wood in forum Affiliate Marketing Events
    Replies: 63
    Last Post: 22-07-05, 06:33 PM
  3. Conflicting Affiliate Cookies
    By darrenw in forum Affiliate Marketing Lounge
    Replies: 26
    Last Post: 25-10-04, 11:31 PM
  4. British NIC
    By paidonresults in forum Paid On Results
    Replies: 5
    Last Post: 05-03-03, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2