Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

MOD for running across more than one affilaite network

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 11-25-2005, 12:15 PM
 
cotc2001 cotc2001 is offline
 

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

Default

I've just edited the above code (home.tpl section) as i found that there was a problem with the cookie resetting if moved to a different page with a variable (sorry we didn't see it before as we use the DSFU mod) the code now checks for the aw or af end to the url (those two will need changing depending on the networks you use)
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
  #3  
Old 11-26-2005, 05:04 AM
 
jsa jsa is offline
 

Senior Member
  
Join Date: Oct 2005
Posts: 197
 

Default

This, my friend, is awesome. I was wondering exactly how to do this recently, and I think I even asked you about it in another thread.

Thanks so much for sharing this!

You are great.

PS - If you were willing to customize this to individual's circumstances here (selection of affiliate programs), this would make a great paid mod.

I know I'd be happy to pay to have this individualized to my circumstances. In the near future, I'm probably going to be running X-Cart Affiliate & MyReferer. Maybe Share-a-Sale, too.
__________________
Building: X-Cart GoldPlus 4.6.1
Old cart:
XC 4.0.17 FComp-RMA-AOM-OFF-Affil
BCSE: Referral Pts-Surveys-BatchUp-OrderEZ- Reviews-RSS
FT: Glossary-OptCopt-AdvSrch-Recently Viewed-Also Bought
CM: eZConversion
XP: SalesRecovery, MultCrncy
Reply With Quote
  #4  
Old 11-26-2005, 05:57 AM
 
cotc2001 cotc2001 is offline
 

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

Default

There isn't realy much to do for customising - not sure how it would work with x-affiliate as i don't think x-affiliate uses a trigger script like proper networks.
Im not a coder at all - this was done between DANUK from here and another guy at the a4uforum.co.uk - i just sat in the middle testing but im sure neither of them would mind the share.
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:04 PM.

   

 
X-Cart forums © 2001-2020