function _googleanalytics_visibility_pages in Google Analytics 6.3
Same name and namespace in other branches
- 5 googleanalytics.module \_googleanalytics_visibility_pages()
- 6.4 googleanalytics.module \_googleanalytics_visibility_pages()
- 6 googleanalytics.module \_googleanalytics_visibility_pages()
- 6.2 googleanalytics.module \_googleanalytics_visibility_pages()
- 7.2 googleanalytics.module \_googleanalytics_visibility_pages()
- 7 googleanalytics.module \_googleanalytics_visibility_pages()
Based on visibility setting this function returns TRUE if GA code should be added to the current page and otherwise FALSE.
2 calls to _googleanalytics_visibility_pages()
- googleanalytics_footer in ./
googleanalytics.module - Implementation of hook_footer() to insert JavaScript at the end of the page.
- googleanalytics_init in ./
googleanalytics.module - Implementation of hook_init().
File
- ./
googleanalytics.module, line 507 - Drupal Module: GoogleAnalytics Adds the required Javascript to the bottom of all your Drupal pages to allow tracking by the Google Analytics statistics package.
Code
function _googleanalytics_visibility_pages() {
static $page_match;
// Cache visibility setting in hook_init for hook_footer.
if (!isset($page_match)) {
$visibility = variable_get('googleanalytics_visibility', 0);
$setting_pages = variable_get('googleanalytics_pages', GOOGLEANALYTICS_PAGES);
// Match path if necessary.
if (!empty($setting_pages)) {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($setting_pages);
if ($visibility < 2) {
// Convert the Drupal path to lowercase
$path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $pages);
}
// When $visibility has a value of 0, the tracking code is displayed on
// all pages except those listed in $pages. When set to 1, it
// is displayed only on those pages listed in $pages.
$page_match = !($visibility xor $page_match);
}
else {
$page_match = drupal_eval($setting_pages);
}
}
else {
$page_match = TRUE;
}
}
return $page_match;
}