track.php invalid code

Community Based Support for JROX Affiliate Manager Only
Post Reply
visorcraft
Posts: 1
Joined: Mon Apr 13, 2015 10:26 pm

track.php invalid code

Post by visorcraft » Mon Apr 13, 2015 10:33 pm

Hi,

I would like to make the following suggestion to your track.php code:

Code: Select all

<?php
if (!empty($_GET['u'])) {
	
	$url = 'http://'.$AFFILIATE_SCRIPT_DOMAIN.'/js/remote/1/' . $_GET['u'] . '/username/'.$KEY;
	
	if(!function_exists('curl_init')) {
		$c = file_get_contents($url);
	} else {
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Affiliate Software Tracking Request');
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '50');
		$c = curl_exec($ch); //execute post and get results
		curl_close($ch);
	}

	$cid = json_decode($c, true);
	$cookie_expires = 1 * 60 * 60 * 24 * 365;
	$cookie_domain = '.'.$DOMAIN; //DON'T FORGET THE . (dot) before the domain
	setcookie('jamcom', $cid['value'], time()+$cookie_expires,"/", $cookie_domain);
}

//header("HTTP/1.1 301 Moved Permanently");
header("Location: http://'.$AFFILIATE_SCRIPT_DOMAIN.'/refer/id/");
exit();
?>
Obviously replace $AFFILIATE_SCRIPT_DOMAIN, $KEY, and $DOMAIN with actual values.

Things that this resolves are:
1) it will give preference to using cURL over file_get_contents (which many webhosts have disabled, and many more do not allow remote URLs)
2) it fixes the json_decode($c) call to actually be an array, hence json_decode($c, true)

Otherwise, I was noticing there were no click actions and I had to debug the track.php script. The changes above resolved it for me.

User avatar
forumadmin
Site Admin
Posts: 399
Joined: Fri Nov 07, 2014 4:50 pm

Re: track.php invalid code

Post by forumadmin » Tue Apr 28, 2015 6:10 pm

nice!

thanks for the code!

maxobi
Posts: 6
Joined: Tue Oct 20, 2015 12:22 am

Re: track.php invalid code

Post by maxobi » Tue Dec 20, 2016 10:02 pm

The truth is that I do not know what to change to make it work, I'm looking for the way and I can not make it work. Any examples?

User avatar
forumadmin
Site Admin
Posts: 399
Joined: Fri Nov 07, 2014 4:50 pm

Re: track.php invalid code

Post by forumadmin » Sat Dec 24, 2016 2:18 am

the track.php code is only needed if you want to track remote domains. if you install JAM on the same domain as where your store is, you don't need to use track.php.

RINASZ
Posts: 2
Joined: Sun Dec 24, 2017 6:21 pm

Re: track.php invalid code

Post by RINASZ » Thu Jan 11, 2018 7:08 am

Hi all,

I am unable to install track.php on my current Shopify platform. Currently, I have hosted the affiliate system on another site and trying to track clicks from my store site. I set up everything and all works well, but I cannot track clicks as I am unable to install track.php to my store site. Anyone encountered an issue on how to track remote domains without track.php? I contacted the support but its two weeks no reply. Appreciate if anyone can assist me on this. Thanks.

Post Reply