function getclicky_page_build in Clicky - Web Analytics in Real Time 7
Same name and namespace in other branches
- 8 getclicky.module \getclicky_page_build()
Implements hook_page_build().
File
- ./
getclicky.module, line 63
Code
function getclicky_page_build(&$page) {
global $user;
// Don't track page views in the admin sections
//@TODO: use path_get_admin_paths() instead of arg(0) comparison to admin.
if (__getclicky_track_or_not($user)) {
$site_id_number = trim(variable_get('getclicky_site_id_number', ''));
// Site search tracking support.
$url_custom = '';
if (module_exists('search') && variable_get('getclicky_site_search', FALSE) && arg(0) == 'search') {
$keys = search_get_keys();
$url_custom = url('search/' . arg(1), 'search=' . trim($keys));
}
// Surround custom urls with single quotes.
if (!empty($url_custom)) {
$url_custom = drupal_to_js($url_custom);
}
$script = __getclicky_output_js_code($site_id_number);
// Optionally pass username data to Clicky by adding additional code
// BEFORE the Clicky tracking code.
if (variable_get('getclicky_pass_username', FALSE) && isset($user->name)) {
$script = '<script type="text/javascript">
var clicky_custom = {session: {username: "' . $user->name . '"}};
</script>' . $script;
}
$page['page_bottom']['getclicky'] = array(
'#type' => 'markup',
'#markup' => $script,
);
}
}