Skip navigation
Help

hook_ucga_display

6 hooks.php hook_ucga_display()
7 uc_googleanalytics.api.php hook_ucga_display()

Determines whether e-commerce tracking code should be added to the page.

The Google Analytics module takes care of adding the necessary .js file from Google for tracking general statistics. The UC Google Analytics module works in conjunction with this code to add e-commerce specific code. However, the e-commerce code should only be added on appropriate pages. Generally, the correct page will be the checkout completion page at cart/checkout/complete. However, because modules can change the checkout flow as necessary, it must be possible for alternate pages to be used.

This hook allows other modules to tell the UC Google Analytics module that it should go ahead and add the e-commerce tracking code to the current page. A module simply needs to implement this hook and return TRUE on the proper order completion page to let UC Google Analytics know it should add the e-commerce tracking code to the current page.

The implementation below comes from the 2Checkout.com module which uses an alternate checkout completion page.

Return value

TRUE if e-commerce tracking code should be added to the current page.

Related topics

1 function implements hook_ucga_display()

1 invocation of hook_ucga_display()

File

ubercart/uc_googleanalytics/uc_googleanalytics.api.php, line 36
Hooks provided by the Google Analytics for Ubercart module.

Code

function hook_ucga_display() {
  // Tell UC Google Analytics to display the e-commerce JS on the custom
  // order completion page for this module.
  if (arg(0) == 'cart' && arg(1) == '2checkout' && arg(2) == 'complete') {
    return TRUE;
  }
}