function hook_commerce_google_analytics_transaction_alter in Commerce Google Analytics 8
Alter transaction array data for Ecommerce Tracking.
Parameters
array $transaction: Transaction array for Ecommerce Tracking to be altered.
array $context: An array with the following keys:
- order: The order.
See also
\Drupal\commerce_google_analytics\EventSubscriber\SendOrderAnalyticsSubscriber::buildGaPushParams()
1 invocation of hook_commerce_google_analytics_transaction_alter()
- SendOrderAnalyticsSubscriber::buildGaPushParams in src/
EventSubscriber/ SendOrderAnalyticsSubscriber.php - Builds the Ecommerce Tracking data array needed by GA Push API for a given order.
File
- ./
commerce_google_analytics.api.php, line 25 - Hooks provided by the Commerce Google Analytics module.
Code
function hook_commerce_google_analytics_transaction_alter(array &$transaction, array $context) {
$transaction['affiliation'] = 'Custom store or affiliation';
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $context['order'];
$transaction['order_id'] = $order
->getOrderNumber();
}