You are here

function hook_commerce_google_tag_manager_commmerce_data_alter in Commerce Google Tag Manager 7.2

Allow other modules to alter data for a single event before aggregation. The $data array structure changes depending on the event that is executed.

The $context variable is an associative array with the following keys:

  • event : the event that is sending the Commerce data to Google TagManager.
1 invocation of hook_commerce_google_tag_manager_commmerce_data_alter()
CommerceGoogleTagManagerBaseAction::pushCommerceData in includes/CommerceGoogleTagManagerBaseAction.php
Builds and pushes the current commerce data.

File

./commerce_google_tag_manager.api.php, line 45
Documentation of Commerce GoogleTagManager hooks.

Code

function hook_commerce_google_tag_manager_commmerce_data_alter(&$data, $context) {

  // If we're sending a "Checkout" event,
  if ($context['event'] == 'checkout') {

    // Change the 'option' data
    $data['ecommerce']['checkout']['actionField']['option'] = 'Overwritten Option';
  }
}