You are here

function uc_googleanalytics_display in Ubercart 5

Same name and namespace in other branches
  1. 8.4 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()
  2. 6.2 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()
  3. 7.3 uc_googleanalytics/uc_googleanalytics.module \uc_googleanalytics_display()

Determines whether or not to display the e-commerce related JS through GA on the current page.

Return value

TRUE or FALSE indicating whether or not to display the GA e-commerce JS.

1 call to uc_googleanalytics_display()
uc_googleanalytics_footer in uc_googleanalytics/uc_googleanalytics.module
Implementation of hook_footer().

File

uc_googleanalytics/uc_googleanalytics.module, line 60
Adds the required HTML and Javascript to the checkout complete page to allow e-commerce statistics tracking through Google Analytics.

Code

function uc_googleanalytics_display() {

  // Display the GA e-commerce JS if the URL is cart/checkout/complete...
  if (arg(0) == 'cart' && arg(1) == 'checkout' && arg(2) == 'complete') {
    return TRUE;
  }

  // Or if the URL is the custom completion page.
  $completion_page = variable_get('uc_cart_checkout_complete_page', '');
  if (!empty($completion_page) && $completion_page == $_GET['q']) {
    return TRUE;
  }

  // Or if another module says this is the page through hook_ucga_display().
  foreach (module_invoke_all('ucga_display') as $result) {
    if ($result === TRUE) {
      return TRUE;
    }
  }

  // Otherwise return FALSE.
  return FALSE;
}