Developers

We want to make tracking as easy as possible for developers too. We'll add more stuff here later, but this should help.

3rd Party Tracking

The main reason people track is to track signups. Unfortunately, if you are an affiliate you most likely can't track if someone signed up because you can't add your conversion image to the thank you page. Unless the site adds 3rd party tracking! Then it's done for you!

When 3rd party tracking is enabled on a tracker, it passes a variable tet to the link being redirected to. The website will then track this variable with cookies, sessions, or whatever means they detirmine. When the end user joins the site, it then displays the thank you image using the code that was passed. Simple.

Here's how to do it:

Tracking Part 1

This section of code will find the tet variable and store it in sessions and

<?
@session_start();
if(isset($_GET["tet"])){
   @setcookie("tet",$_GET["tet"],time()+86400*30,"/",$_SERVER["HTTP_HOST"],"0");
   $tet = $_SESSION["tet"] = $_GET["tet"];
}elseif (isset($_SESSION["tet"])) {
   $tet = $_SESSION["tet"];
}
elseif (isset($_COOKIE["tet"])) {
   $_SESSION["tet"] = $tet = $_COOKIE["tet"];
}
?>

Tracking Part 2

This section of code will go in your thank you page itself. It'll display the tracking image if available. The image is a 1x1 pixel image and will not be noticable to your customers. Note that the first tracking part needs to be already included.

<?
if ($tet) {
echo "<img src=\"http://trck.me/".str_replace("-","/",$tet)."/\" width=\"1\" height=\"1\">";
}
?>

Listing Tracker URLs

If you run an advertising network, you probably have a list of sites you don't allow. And you probably hate it when people use a link shortener to hide links on you. We'd rather you be able to find problem sites than ban our site entirely, so we've coded a way for you to get a list of the URLs being rotated in a tracker.

Note that this does not take into consideration tagging, filtering, geotargetting, or other options. It only lists all the possible URLs in a tracker. It will return false if it's not a Trck.me tracker.

function get_links($url){
	$url_parts = @parse_url($url);
	if (!$url_parts) return false;
	if (!isset($url_parts['host'])) return false;
	if (!isset($url_parts['path'])) $url_parts['path'] = '/';

	$sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80), $errno, $errstr, 30);
	if (!$sock) return false;

	$request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n";
	$request .= 'Host: ' . $url_parts['host'] . "\r\n";
	$request .= "Connection: Close\r\n\r\n";
	fwrite($sock, $request);
	$response = '';
	while(!feof($sock)) $response .= fread($sock, 8192);
	fclose($sock);

	if (preg_match('/^TrckMe-List: (.+?)$/m', $response, $matches)){
		$listurl = trim($matches[1]);
		$urls = file($listurl);
		return array_map('trim',$urls);
	} else {
		return false;
	}
}