1. Download

1. Download the Trackdrive PHP software development kit.

Download PHP SDK

2. Setup

Upload the library to your website.

1. Unzip trackdrive.zip

2. Upload trackdrive.php to your website using an FTP client.

3. Place the following code at the top of your page:


<?php require('trackdrive.php'); ?>
			

3. Usage

Display a number


<?php show_trackdrive_number('8519320582390jf9082j9032'); ?>
			

Output:


(855) 367-3640
			

Default Number Example

Display a number with a default fallback


<?php 

$options = array(
'default_number' => '(800) 234-1111', 
);

show_trackdrive_number('invalid_offer_id', $options);
show_trackdrive_extension('invalid_offer_id', $options);

?>
			

Output:


(800) 234-1111
			

Advanced Example

Set a default number. Pass additional tokens.


<?php
$options = array(
  'format' => 'plain',
  'default_number' => '(800) 234-1111'
);

$tokens = array('afid' => 'jerry');

show_trackdrive_number('8519320582390jf9082j9032', $options, $tokens);
?>

			

Output:


(800) 234-1111
			

Valid Options

These are the options that can be passed as a second argument to:


<?php show_trackdrive_number($key, $options)?>
Attribute Description
default_number A String that will be outputted if a number isn't available.
format

String

The format for the displayed number. The acceptable values are:

Accepted Value Example
plain +18001231234
human (800) 123-1234

Trackdrive Tokens

Trackdrive exposes a global Array variable $trackdrive_tokens with these predefined tokens and values:

Token Key Token Description
full_url The request url
source_host The http host
source_pathname The url path name
source_query The url query string
ip The remote ip address
useragent The useragent
osversion The operating system
os The operating system
browser The browser
browserversion The browser version

<?php
$options = array();

// setup any tokens you want to add or override from the URL
$tokens = array(
  'fu'  =>  $trackdrive_tokens['full_url'],
  'sh'  =>  $trackdrive_tokens['source_host'],      // 'website.com'
  'sp'  =>  $trackdrive_tokens['source_pathname'],  // 'somepath'
  'sq'  =>  $trackdrive_tokens['source_query'],     // '?query=ae'
  'ip'  =>  $trackdrive_tokens['ip'],               // '192.168.0.1'
  'ua'  =>  $trackdrive_tokens['useragent'],        // 'Mozilla/5.0 '
  'osv' =>  $trackdrive_tokens['osversion'],        // 'Mac OS X'
  'os'  =>  $trackdrive_tokens['os'],               // 'Mac'
  'b'   =>  $trackdrive_tokens['browser'],          // 'Chrome'
  'bv'  =>  $trackdrive_tokens['browserversion'],   // '50.0.2661.94'
);

show_trackdrive_number('8519320582390jf9082j9032', $options, $tokens);
?>
		

Valid Query Parameters

These are the options that can be passed by the url:

Attribute Description
dn The default number that will be used if a number isn't available.
tfn

Display a cached plain number instead of requesting another number from the API.

If $_GET['tfn'] is set this number will be used instead of requesting a number from the trackdrive API.

This is useful if you want to redirect the user somewhere and display a number you've already pulled on a previous page.

ftfn

Display a cached formatted number instead of requesting another number from the API.

If $_GET['ftfn'] is set this number will be used instead of requesting a number from the trackdrive API.

Troubleshooting

Debug unexpected results with:


  <?php get_trackdrive_number('8519320582390jf9082j9032', $options, $tokens); ?>

  <?php print_r($trackdrive_debug); ?>

  <?php print_r($trackdrive_error); ?>