Affiliate Software Documentation
Setting Tracking Cookies Using PHP
If you want to set tracking cookies on your domain pages without the user having to click on an affiliate link, you can use this option.For example, if you just want to append the affiliate's username to a specific PHP page on your site, like a product page, you can use this.
First, enable the automation API in JAM
- Go to Settings > Global Configuration > Automation > Enable Signup And Login Automation
- Set the Access Key and Secret ID
$url = 'http://www.yourdomain.com/affiliates'; $access_key = 'YOUR_ACCESS_KEY'; $access_id = 'YOUR_ACCESS_ID'; $username = $_GET['affiliate']; $sdata = array( 'access_key' => $access_key, 'access_id' => $access_id, 'ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'subdomain' => $username, //affiliate username ); $fields = ""; foreach( $sdata as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&"; $ch = curl_init($url . '/automate/' . $type); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '50'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); $resp = curl_exec($ch); curl_close ($ch); $result = json_decode( $resp); $jam_cookie = $result->msg; if (setcookie( $jam_cookie->name, $jam_cookie->value, $jam_cookie->expire, $jam_cookie->path, $jam_cookie->domain, 0 )) { echo 'SUCCESS: tracking_cookie_set'; }';