function ga_push_add_legacy_params in GA Push 8
Same name and namespace in other branches
- 7 ga_push.module \ga_push_add_legacy_params()
Maps old method keys to the new ones.
This function is for legacy compatibility and will be removed on next releases.
Parameters
array $push: Push data.
string $type: Push type.
1 call to ga_push_add_legacy_params()
- ga_push_add in ./
ga_push.module - Add a new google analytics tracking push.
File
- ./
ga_push.module, line 229 - Drupal Module: GA Push.
Code
function ga_push_add_legacy_params(array $push, $type) {
switch ($type) {
case GA_PUSH_TYPE_ECOMMERCE:
// Transaction:
$push_legacy_trans_map = [
'order_id' => 'id',
'total' => 'revenue',
'total_shipping' => 'shipping',
'total_tax' => 'tax',
];
$push['trans'] = ga_push_push_data_mapper($push_legacy_trans_map, $push['trans']);
// Items:
$push_legacy_items_map = [
'order_id' => 'id',
];
foreach ($push['items'] as $key => $value) {
$push['items'][$key] = ga_push_push_data_mapper($push_legacy_items_map, $value);
}
break;
default:
$push_legacy_map = [
// Event:
'category' => 'eventCategory',
'action' => 'eventAction',
'label' => 'eventLabel',
'value' => 'eventValue',
'non-interaction' => 'nonInteraction',
];
// Mapping.
$push = ga_push_push_data_mapper($push_legacy_map, $push);
}
return $push;
}