Jump to content

Php code to track affiliate redirections from my site


SandeepCharanU

Recommended Posts

Hi

      This is sandeep charna i was new to PHP i am designing a site on PHP in that i would like to put affiliate links(i am a publisher) if any of my site visitors clicks that link and register with that site or signup with that redirected URL his signup process will complete and i will get one lead it is recorded in my merhant's database, i want to track that record if lead is generated i need to know how can i track my visitors weather he/she completed the process or not. i tried so many processes but no use can any one please help me to do this, Please suggest any process or code to track this.

<?php

require_once "outbound-tracking.php";  /* The tracking file you upload - I renamed mine to something unique */
PiwikTracker::$URL = 'http://www.your-site.com/mystats/';  /* The URL specified in your site tracking code */
$piwikTracker = new PiwikTracker( $idSite = 1 );  /* The Site ID also found in your tracking code */
$piwikTracker->setTokenAuth( 'your-auth-code-here' );  /* The token_auth found on the API page of your CP - required to get users IP */
$piwikTracker->setVisitorId($piwikTracker->getVisitorId());  /* You need to add this so the user id isn't lost and thier tracking starts over */
$piwikTracker->setIp( $_SERVER['REMOTE_ADDR'] );  /* Log visitor IP if you like */
$piwikTracker->setUrl($url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );  /* Set the current URL */
$piwikTracker->doTrackPageView( $_GET['id'] );  /* Log the Visit */
?>

<?php
     $id = $_GET['id'];
     $redirect = array(

'name1'=>'http://www.affiliatelink1.com/'
'name2'=>'http://www.affiliatelink2.com/'

           );
     header('HTTP/1.1 301 Moved Permanently');
     header('Location:'.$redirect[$id]);
     header('Connection: close');
     exit();
?>

This is the code i was using but it was recording only the affiliate link what is the user selected on my site but i want to record weather He/She generate the lead to me or not.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.