function ga_push_analyticsjs_measurement_protocol_mapping_enhanced_ecommerce_item in GA Push 7
Map enhanced ecommerce item (product, product impression) to measurement protocol format.
@TODO: allow mapping for product impressions(il<listIndex>pi<productIndex>)!
Parameters
array $item: Enhanced ecommerce item.
int $index: Enhanced ecommerce index in the list of items.
string $type: Product type key prefix (pr, promo, etc).
1 call to ga_push_analyticsjs_measurement_protocol_mapping_enhanced_ecommerce_item()
- ga_push_method_utmp_php_construct_enhanced_ecommerce_request_data in inc/
ga_push.utmp.php.inc - Returns data arrays for a enhanced eCommerce tracking.
File
- ./
ga_push.module, line 880 - Drupal Module: GA Push.
Code
function ga_push_analyticsjs_measurement_protocol_mapping_enhanced_ecommerce_item($item, $index, $type) {
$map = ga_push_analyticsjs_measurement_protocol_map_enhanced_ecommerce_item();
$data_mapped = array();
foreach ($item as $key => $value) {
$mkey = isset($map[$key]) ? $map[$key] : $key;
// Replace custom dimensions and metrics that uses Analytics.js keys with UTMP keys.
$mkey = str_replace(array(
'dimension',
'metric',
), array(
'cd',
'cm',
), $mkey);
if (in_array($mkey, $map) || preg_match('/^(cd|cm)[0-9]*/', $mkey)) {
// Map enhanced ecommerce vars.
$data_mapped[$type . $index . $mkey] = $value;
}
}
return $data_mapped;
}