I want to track an event: when people come in from an external banner posted on an affiliate website.
For example, on an affiliate website they have a link to my website, http://mysite.com/?bid=1
Is this the best way to do it, or is there a better way that I'm missing?
/**
* Track an inbound banner hit
*/
function hook_footer() {
if (isset($_GET['bid') && module_exists('googleanalytics')) {
$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d AND type = '%s'",
$_GET['bid'],
'banner'));
$category = 'Banners';
$action = 'Inbound hit';
$label = $title;
$value = $_GET['bid'];
$script = "pageTracker._trackEvent('$category', '$action', '$label', $value)";
drupal_add_js($script, 'inline', 'footer');
}
}
Comments
Comment #1
hass commentedSee #231451: Add hook to alter data before sending it to browser