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.

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.