You are here

function googleanalytics_preprocess_search_results in Google Analytics 6.3

Same name and namespace in other branches
  1. 6.4 googleanalytics.module \googleanalytics_preprocess_search_results()
  2. 7.2 googleanalytics.module \googleanalytics_preprocess_search_results()
  3. 7 googleanalytics.module \googleanalytics_preprocess_search_results()

Implementation of hook_preprocess_search_results().

Collects the number of search results. It need to be noted, that this function is not executed if the search result is empty.

File

./googleanalytics.module, line 363
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_preprocess_search_results(&$variables) {

  // There is no search result $variable available that hold the number of items
  // found. But the pager item mumber can tell the number of search results.
  global $pager_total_items;
  drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', 'inline', 'header');
}