Jump to content

Affiliate Query


Terra

Recommended Posts

I've got 2 parts to my site - the main selling site (e.g. http://www.mydomain.com) and WHCMS on a sub-domain with its own IP address (e.g. support.mydomain.com).

 

Query: will affiliate still work, if customers first come to my main site & then go on to WHMCS later to pay? My initial thought is that it won't work - as the link will go to a non-WHMCS page, so no cookie will be created & the affiliate ID in the link will be lost:

Affiliate Link -> non-WHMCS generic sales page -> WHCMS for paying

 

Is there any way to tie my non-WHMCS pages into the WHMCS affiliate system so sales are tracked across both domains?

 

Any help appreciated!

 

[edit]mh - one more thought: I guess I could direct affiliate links to a WHMCS page & then put in a redirect to my other pages (so cookie gets triggered & then customers get forwarded to the sales page). But bit of a run-around ... if I could trigger the cookie on my non-WHMCS pages would be neater [/edit]

Link to comment
Share on other sites

All you need is to put this code in your php code

 

include("dbconnect.php");

if (isset($aff)) {

update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));

setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60,'/',''.mydomain.com);

}

 

//if you put a '/', your cookie will be made available through out the domain

//if you put a '.mydomain.com', your cookie will be made available through out all the subdomains of .mydomain.com

Link to comment
Share on other sites

The db connect won't work as it's 2 separate sites on 2 different serves, so I can't access the WHMCS database from the other pages.

 

Would it work if I just set the cookie without anything else? I appreciate that the stats may not be correct then, but would at least the commissions work?

 

Edith

Link to comment
Share on other sites

Hi Terra,

 

You're absolutely right about this, you can set only the cookie, without the db connection and update query would only affect the stats.

 

You can check by using to see if the cookie is written.

print_r($_COOKIE);

Link to comment
Share on other sites

I think I figured this now out - the affiliate link goes automatically to:

http://sub.mydomain.com/*?aff=XX

 

So all I did was amend the redirect in * (header redirect) to point to my sales pages. That way, cookie gets triggered and customers to the page I want to send them to.

 

I've also added a $_GET[link] variable (which I will advise to select affiliates), so that I can further refine to which page customers are sent, plus a default for standard affiliates.

 

So in * I've now got:

 

switch($_GET[link]) {

case 'something':

header("Location: http://mydomain.com/some_sales_page.php");

break;

 

default:

header("Location: http://mydomain.com/sales_page.php");

break;

}

 

Many thanks for your help on this forum - much appreciated. Edith

Link to comment
Share on other sites

Update - had to make one more change in * to get it it work:

 

if (isset($aff)) {
update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
 setcookie("WHMCSAffiliateID", $aff, time()+7*24*60*60,'/',''.domain.com);	
}

header("HTTP/1.1 301 Moved Permanently"); 

switch($_GET[link]) {
case 'something':
 header("Location: http://mydomain.com/some_sales_page.php");
 break;

default:
 header("Location: http://mydomain.com/sales_page.php");
 break;
}

 

NB: please note that johnmigen's advice about changing the cookie to add the domain name is vital, as otherwise the affiliate tracking does not work.

 

Edith

Link to comment
Share on other sites

  • 1 month later...

For some partners we have created dedicated pages on our site - one per affiliate. How would I use the code below to embed the affiliate code either into the affiliates web page or for when a purchase button is clicked?

 

Thanks

 

Nabil

 

 

All you need is to put this code in your php code

 

include("dbconnect.php");

if (isset($aff)) {

update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));

setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60,'/',''.mydomain.com);

}

 

//if you put a '/', your cookie will be made available through out the domain

//if you put a '.mydomain.com', your cookie will be made available through out all the subdomains of .mydomain.com

Link to comment
Share on other sites

  • 1 year later...

I'm running wordpress as the front end part of my website and WHMCS as the client area/shopping cart, I added the following code to my wordpress template header however it is not tracking orders, it will update the affiliates count with a visit count but it wont give them credit for the sale.

 

Any help would be greatly appreciated.

 

include("/dashboard/dbconnect.php");
if (isset($aff)) {
update_query("tblaffiliates",array("visitors"=>"+1 "),array("id"=>$aff));
setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60,'/',''.'/');
}

Link to comment
Share on other sites

If it's registering the hit then it might be an admin thing. If you pull up the affiliate, do you see a list of customers referred by them? Sounds like it isand this is a settigns problem.

 

1. You need to approve orders

2. In the settings of the affiliate, you set a delay for when they are credited for the sale and this is after payment has been made.

 

Nabil

 

 

 

I'm running wordpress as the front end part of my website and WHMCS as the client area/shopping cart, I added the following code to my wordpress template header however it is not tracking orders, it will update the affiliates count with a visit count but it wont give them credit for the sale.

 

Any help would be greatly appreciated.

 

include("/dashboard/dbconnect.php");
if (isset($aff)) {
update_query("tblaffiliates",array("visitors"=>"+1 "),array("id"=>$aff));
setcookie("WHMCSAffiliateID", $aff, time()+90*24*60*60,'/',''.'/');
}

Link to comment
Share on other sites

hm, well I set the delay to 0 and it is still not showing up, I'm thinking it could be a few things.... I'm running test transactions with payment gateway set to test mode, would that be a reason for the commission not showing?

 

Here are my affiliate settings, I have comission set to 0% but I have a special commission setup for each product.

00000448.png

Edited by BryanB
Link to comment
Share on other sites

Just checked my cookies in firefox and it looks like I have the cookie for the right affiliate... Can't figure out why it wont work. I tried signing up as a new customer, setting the default commission to 1% and accepting the order.. still nothing.

 

00000450.png

Link to comment
Share on other sites

I'd guess that the affiliate module isn't triggering in the transaction. Is the product set to work with affiliates?

 

When it's successful, under the user affiliate profile you'll first see a list of the transactions that generated commisions and then after the period of time you elected for payout after they've paid, you'll see them lower down the page waiting to be paid out.

Link to comment
Share on other sites

The product is set to pay a $50 fixed commission to affiliates... (screen shot above). I dont think there is anywhere else that I have to turn it on?

 

The affiliates transaction screen isnt showing anything and looks like this:

 

00000452.png

Link to comment
Share on other sites

  • 8 years later...

Hey Guys,

I know this is an old topic but for people that are looking for an alternative answer, here is a simple way that works.

Ideally you would put this in the footer of your external website, just change [WHMCS_AREA_DOMAIN_HERE] to the domain of your WHMCS client area.

It probably isn't the best way, but it certainly is the simplest and avoids multiple database connections.

<?php 
	if ( isset( $_GET[ 'aff' ] ) )
		echo '<iframe src="[WHMCS_AREA_DOMAIN_HERE]/aff2.php?aff=' . $_GET[ 'aff' ] . '" style="display:none"></iframe>';
?>

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated