=== modified file 'payment/uc_2checkout/uc_2checkout.module' --- payment/uc_2checkout/uc_2checkout.module 2008-05-28 23:17:31 +0000 +++ payment/uc_2checkout/uc_2checkout.module 2009-01-09 15:49:45 +0000 @@ -35,6 +35,17 @@ } /** + * Implementation of hook_ucga_display(). + */ +function uc_2checkout_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; + } +} + +/** * Implementation of hook_form_alter(). */ function uc_2checkout_form_alter($form_id, &$form) { @@ -273,7 +284,7 @@ // Empty that cart... uc_cart_empty($cart_id); - + // Save changes to order without it's completion (it will be on finalization step) uc_order_save($order); === modified file 'uc_googleanalytics/uc_googleanalytics.module' --- uc_googleanalytics/uc_googleanalytics.module 2008-07-14 22:10:46 +0000 +++ uc_googleanalytics/uc_googleanalytics.module 2009-01-09 15:51:37 +0000 @@ -16,10 +16,8 @@ * Implementation of hook_footer(). */ function uc_googleanalytics_footer($main = 0) { - $completion_page = variable_get('uc_cart_checkout_complete_page', ''); - // Check to see if we are at the order completion page. - if ((arg(0) == 'cart' && arg(1) == 'checkout' && arg(2) == 'complete') || (!empty($completion_page) && $completion_page == $_GET['q'])) { + if (uc_googleanalytics_display()) { // If we can load the order... if ($order = uc_order_load($_SESSION['uc_googleanalytics_order_id'])) { // Check for which GA version is being used. @@ -53,6 +51,32 @@ } } +// Determines whether or not to display the e-commerce related JS through GA on +// the current page. +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; +} + // Creates the script for the legacy GA code. function _uc_googleanalytics_ecommerce_legacy_script($order) { $script = '';