Skip to content

Instantly share code, notes, and snippets.

@zaneclaes
Last active August 29, 2015 14:08
Show Gist options
  • Save zaneclaes/830b3fc80cf99a2009dc to your computer and use it in GitHub Desktop.
Save zaneclaes/830b3fc80cf99a2009dc to your computer and use it in GitHub Desktop.
<?php
if(!isset($_POST['device']) || !isset($_POST['os_version'])) {
die('missing params');
}
$params = $_POST;
$params['ip'] = sha1($_SERVER['REMOTE_ADDR']);
// Now we'd query the database for a Referral object match on device, os_version, and ip
// We could also restrict our query to recently created Referral objects and/or objects
// which have not been "Claimed."
// Once the object is found, we would modify it to be "claimed" by adding some user-specific
// information, such as a user ID
// assuming we have an object $referral and an object id $objId for that object,
// we can now do this to track the referral attribution in Google Analytics:
$objId = $referral['objectId'];
$ganuid = $referral['ganuid'];
$gan->pageview(array('page'=>'installed?ref='.$objId,'title'=>$objId), $referral, $ganuid);
// (note that I've skipped over initializing the $gan object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment