Skip navigation
Help

hook_ucga_trans_alter

6 hooks.php hook_ucga_trans_alter(&$trans, $order)
7 uc_googleanalytics.api.php hook_ucga_trans_alter(&$trans, $order)

Allows modules to alter the transaction data passed to Google Analytics.

The UC Google Analytics module constructs function calls that work through the Google Analytics JS API to report order information for e-commerce tracking purposes. The module builds the argument list for the transaction and uses this hook to give other modules a chance to alter what gets reported to Google Analytics.

Parameters

$trans: An array of arguments being passed to Google Analytics representing the transaction, including order_id, store, total, tax, shipping, city, state, and country.

$order: The order object being reported to Google Analytics.

Return value

Nothing should be returned. Hook implementations should receive the $trans array by reference and alter it directly.

Related topics

1 invocation of hook_ucga_trans_alter()

File

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

Code

function hook_ucga_trans_alter(&$trans, $order) {
  // Example implementation: prefix all orders with "UC-".
  $trans['order_id'] = 'UC-' . $trans['order_id'];
}