Page 1 of 1
Affiliate priority of cookies
Posted: Tue Sep 18, 2012 1:12 am
by skimottaret
We have implemented several affiliates links and this is all working within our shop
does anyone know how opencart handles the situation if a customer had clicked on links from multiple affiliates before actually making a purchase?
say a user clicks though initially from affiliate 1 site doesnt buy but then returns a few weeks later from a link on affiliate 2 website and then concludes the transaction.
Which affiliate would be credited with the commission? The first, the most recent cookie or ??
Re: affiliate priority for cookies
Posted: Wed Sep 19, 2012 4:27 am
by Avvici
Each URL that is tied to that particular purchase has an affiliate ID tied within it. A purchase is a purchase no matter where it comes from. During the order confirmation the code checks for a cookie that is set.
The url that is created for tracking would look something like this:
Code: Select all
'link' => str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode()))
In the core of open cart there is ALWAYS a cookie being set as soon as a URL is sent to the core via $_GET.
Here is the code that makes the affiliates connecting UNIQUE (all of the time)
Code: Select all
if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}
No matter how many people connect and when....there is always an affiliate ID within a cookie, created by the index core (which is searching for a $_GET). You can send 100 connections to the Open Cart at the same time. There will be 100 individual cookies set that are tied to a particular AFFILIATE.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Wed Sep 19, 2012 5:32 am
by skimottaret
thanks avvici, I'm not a programmer but is there a rule for which cookie gets the priority?
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Wed Sep 19, 2012 6:53 am
by SXGuy
yes, the link that is used to checkout from.
If someone followed an affiliate link last week, looked at the item, didnt buy, left, closed the window, turned the computer off. A week later, follows a link from another affiliate, but actually buys the product.
Then obviously, the affilate who gets the comission, is the one whos link was used to purchase the item.
It would be a bit silly to continually track all affiliates linked to a product that has been viewed, since product inception.
And since no purchase was made on the first attempt, its only fair that they dont receive the commission.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Wed Sep 19, 2012 4:09 pm
by skimottaret
Thanks SXGuy, we have had this come up and need to let our affiliates know the "rules" and will advise that the most recent click through gets the commission.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Thu Sep 20, 2012 2:13 am
by Avvici
skimottaret wrote:thanks avvici, I'm not a programmer but is there a rule for which cookie gets the priority?
As I explained, there really is no priority. It's based on the present link to checkout.

Re: AFFILIATE PRIORITY OF COOKIES
Posted: Thu Sep 20, 2012 2:41 am
by skimottaret
interesting as during testing it looks as though if a customer clicks through from affiliate 1's link and makes a purchase THEN after loggin out and clicks through from affilate 2 link and makes a second purchase in another session affiliate 1 gets the commission in our opencart shop
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Thu Sep 20, 2012 3:15 am
by SXGuy
hmm, then that is a bug, if thats true for all carts. Maybe you should raise it in the bug thread.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Thu Sep 20, 2012 4:07 am
by Avvici
skimottaret wrote:interesting as during testing it looks as though if a customer clicks through from affiliate 1's link and makes a purchase THEN after loggin out and clicks through from affilate 2 link and makes a second purchase in another session affiliate 1 gets the commission in our opencart shop
Huh? That makes 0 sense.....where is the second affiliate link? Send both URL's for the separate affiliate links.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Sat Oct 06, 2012 7:41 pm
by ocmta
skimottaret wrote:interesting as during testing it looks as though if a customer clicks through from affiliate 1's link and makes a purchase THEN after loggin out and clicks through from affilate 2 link and makes a second purchase in another session affiliate 1 gets the commission in our opencart shop
This is true, and also even a user's first visit was via affilaite 1's link, but he didn't buy anything, and then later visits and buy via affiliate 2's link, still only affiliate 1 gets the commission.
Affiliate 1's tracking code cookie will stay saved in cookies for 1000 days, and won't be replaced by any other affiliate's tracking code no matter what (unless the user clears cookies, of course).
This actually makes some sense, and many affiliate programs work that way, because 2nd, 3rd etc. affiliates direct the user to a site he knows already, while the 1st affiliate was the one who "showed" this site to the user, and deserves more credit. This is controversial, though.
Re: AFFILIATE PRIORITY OF COOKIES
Posted: Sat Oct 06, 2012 9:33 pm
by Avvici
ocmta wrote:skimottaret wrote:interesting as during testing it looks as though if a customer clicks through from affiliate 1's link and makes a purchase THEN after loggin out and clicks through from affilate 2 link and makes a second purchase in another session affiliate 1 gets the commission in our opencart shop
This is true, and also even a user's first visit was via affilaite 1's link, but he didn't buy anything, and then later visits and buy via affiliate 2's link, still only affiliate 1 gets the commission.
Affiliate 1's tracking code cookie will stay saved in cookies for 1000 days, and won't be replaced by any other affiliate's tracking code no matter what (unless the user clears cookies, of course).
This actually makes some sense, and many affiliate programs work that way, because 2nd, 3rd etc. affiliates direct the user to a site he knows already, while the 1st affiliate was the one who "showed" this site to the user, and deserves more credit. This is controversial, though.
No, this is not true. It should not work that way. Like was mentioned above if that is happening then it is a bug. I need to set something up to try it for myself, to echo out the actual sessions.
Re: Affiliate priority of cookies
Posted: Sat Oct 06, 2012 9:42 pm
by ocmta
Maybe it's not correct behavior, that is arguable, however this is how it works. Look at the code you've posted yourself
Code: Select all
if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}
It basically translates to - that if there is tracking code present in the URL AND there is NO tracking cookie set yet, only then set the tracking cookie for 1000 days. Therefore no tracking code in the URL can replace already existing tracking cookie.
Re: Affiliate priority of cookies
Posted: Sat Oct 06, 2012 10:01 pm
by Avvici
Well yeah, that is what I said. We are talking about two different things. The point is....the system may not be working like it should and needs testing.