View Single Post
  #1  
Old 11-25-2005, 03:47 AM
 
cotc2001 cotc2001 is offline
 

X-Man
  
Join Date: Feb 2003
Location: Shrewsbury, UK
Posts: 2,351
 

Default MOD for running across more than one affilaite network

Ok this mod is with the help of DANUK from these forums along with someone from the a4uforum.

If you run with more than one affiliate network, there can be instances where an affiliate might come through one network, leave without buying but then come back through another affiliate netowork. The result of this is that the customer has both networks cookies on their system and you end up paying two sets of commissions and depending on your policy have to manually reject one.

The mod below will set a local cookie in x-cart called network which will identify the last network referrer and so will only trigger the affiliate tracking script for the last network the customer passed through.

The mod comes in two stages , 1 is not really a mod but you need to sort it out with your affiliate network/s , the second is the actual code - i will be using affiliate future and affiliate window in this example so you will need to change the affiliate tracking scripts to whichever networks you use.

Quote:
1. Speak you our affiliate networks/s and ask them to automatically append a variable to the end of all traffic passed through them - for this example , I asked affiliate future to append ?aff=af and for affiliate window i asked them to clickappend ?aff=aw to the end of all urls passed

In home.tpl enter this javascript to set the cookie

Code:
{literal} <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; } var aff = window.location.search.substring(1); if(aff == ''){ // document.write("don't set the cookie"); } else if(aff != 'aff=af' && aff != 'aff=aw') { // document.write("QueryString is not af or aw"); } else { // document.write(aff.replace(/aff=/,"")) var expdate = new Date (); expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*30)); setCookie('network',aff.replace(/aff=/,""),expdate) } </script> {/literal}

This will set a local called network in your x-cart based on the appended url , so if someone came from an affiliate whos append as ?aff=af then the cookie would contain af , if it was ?aff=aw then the cookie would be aw

next change your order_message.tpl where you would normally have the affiliate tracking script to.


Code:
{section name=oi loop=$orders} {assign var="aff_order" value=$orders[oi].order} {math assign="temp_total" equation="x-y" x=$aff_order.total y=$aff_order.shipping_cost} {if $smarty.cookies.network eq "af"} {literal} <script language="javascript" src="https://scripts.affiliatefuture.com/AFFunctions.js"></script> <script language="javascript"> var merchantID = XXX; var orderValue = {/literal}'{$temp_total}'{literal}; var orderRef = {/literal}'{$aff_order.orderid}'{literal}; var payoutCodes = ''; var offlineCode = ''; AFProcessSaleV2(merchantID, orderValue, orderRef,payoutCodes,offlineCode); </script> {/literal} {elseif $smarty.cookies.network eq "aw"} [img]https://www.awin1.com/sale.php?sale={$temp_total}&extra={$aff_order.orderid}&type=s&mid=XXX[/img] {else} {/if}

Where there is XXX is meant to be your merchants ID

So what this does is that it then checks to see if the network cookie is available and if so which network is being referenced and then only triggers the correct script whilst ignoring the other one.

the cookie lasts for a standard 30 days and we have also tested this with the DSFU mod and it works well.

The way we have it set on our site is that commission is paid ex vat and ex shipping - obviuosuly you might want it different so you would need to change accordingly
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote