View source
<?php
function crazyegg_perm() {
return array(
'administer crazy egg',
);
}
function crazyegg_menu() {
$items['admin/settings/crazyegg'] = array(
'title' => 'Crazy Egg',
'description' => 'Configure Crazy Egg heat maps on your website.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'crazyegg_admin_settings_form',
),
'access arguments' => array(
'administer crazy egg',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'includes/admin.inc',
);
return $items;
}
function crazyegg_help($path, $arg) {
switch ($path) {
case 'admin/settings/crazyegg':
return t('<a href="@url">Crazy Egg</a> is an analytics tool that provides website heatmaps and eye tracking.', array(
'@url' => 'http://www.crazyegg.com',
));
}
}
function crazyegg_footer($main = 0) {
global $user;
$account_id = variable_get('crazyegg_account_id', '');
$crazyegg_enabled = variable_get('crazyegg_enabled', TRUE);
if ($account_id && $crazyegg_enabled) {
$scope = 'footer';
$account_path = str_pad($account_id, 8, "0", STR_PAD_LEFT);
$account_path = substr($account_path, 0, 4) . '/' . substr($account_path, 4, 8);
$account_path = "pages/scripts/" . $account_path . ".js";
$script_host = "dnn506yrbagrg.cloudfront.net";
$script = '
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName(\'script\')[0];
a.src=document.location.protocol+"//' . $script_host . '/' . $account_path . '";
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
';
drupal_add_js($script, 'inline', 'footer');
}
}