zac Posted March 22, 2017 Share Posted March 22, 2017 (edited) Hi there, I'd like to track reduction per product as custom metric on order confirmation. Eg. a product normally sold for $100 is on sale with 25% discount, I want to track the $25 reduction. Therefore I edited in ganalytics.php (Modul ganalytics, V2.3.1) the public function wrapProduct , in specific the $ga_product array (around line 530) So $ga_product = array( 'id' => $product_id, 'name' => Tools::jsonEncode($product['name']), 'category' => Tools::jsonEncode($product['category']), 'brand' => isset($product['manufacturer_name']) ? Tools::jsonEncode($product['manufacturer_name']) : '', //'brand' => Tools::jsonEncode($product['manufacturer_name']), 'variant' => Tools::jsonEncode($variant), 'type' => $product_type, 'position' => $index ? $index : '0', 'quantity' => $product_qty, 'list' => Tools::getValue('controller'), 'url' => isset($product['link']) ? urlencode($product['link']) : '', 'price' => number_format($product['price'], '2') ); is now: $calc_discount = $product['price_without_reduction'] - $product['price']; $ga_product = array( 'id' => $product_id, 'name' => Tools::jsonEncode($product['name']), 'category' => Tools::jsonEncode($product['category']), 'brand' => isset($product['manufacturer_name']) ? Tools::jsonEncode($product['manufacturer_name']) : '', //'brand' => Tools::jsonEncode($product['manufacturer_name']), 'variant' => Tools::jsonEncode($variant), 'type' => $product_type, 'position' => $index ? $index : '0', 'quantity' => $product_qty, 'list' => Tools::getValue('controller'), 'url' => isset($product['link']) ? urlencode($product['link']) : '', 'price' => number_format($product['price'], '2'), 'metric1' => number_format($calc_discount, '2') ); In Google Analytics I defined a new custom metric (Index: 1, scope: product, format: currency) - I also tried hit-scope and integer combinations, all without success. According to Google help center it is definitely possbile and allowed to track custom metrics with transactions Source code on order-confirmation looks fine, still my metric in GA-reports is 0 - although all my test-orders were all reduced products. Any hints for me whats wrong? Thanks in advance, Chris Edited March 22, 2017 by zac (see edit history) Link to comment Share on other sites More sharing options...
zac Posted March 29, 2017 Author Share Posted March 29, 2017 ping Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now