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

hass’s picture

Title: Event tracking » How to track inbound clicks on banners?
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.