Conversion Tracking
-
Hi there
We are setting up conversion tracking. But we have an issue with the tracking of the dynamic currency. Can you suggest a fix around this as we don’t seem to pull the value as per normal woocommerce setup? The rest of the code works.
'currencyCode': '<?php echo $payment_currency; ?>'<script> dataLayer.push({ 'event': 'transaction', 'ecommerce': { 'purchase': { 'actionField': { 'id': '<?php echo $order->get_order_number(); ?>', // Transaction ID. Required 'affiliation': 'Online Store', 'revenue': '<?php echo $order->get_total(); ?>', // Total transaction value (incl. tax and shipping) 'tax': '<?php echo $order->get_total_tax(); ?>', 'shipping': '<?php echo $order->get_shipping_total(); ?>', 'coupon': '<?php echo $coupons[0]; ?>', 'actionField': '<?php echo $payment_title; ?>', 'currencyCode': '<?php echo $payment_currency; ?>' }, 'products': [ <?php $coupons = $order->get_used_coupons(); // LOOP START: Iterate through order items foreach( $order->get_items() as $item_id => $item ) : // Get an instance of the WC_Product object $product = $item->get_product(); // Get the product categories for the product $categories = wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ); $category = reset($categories); // Keep only the first product category ?> { 'name': '<?php echo $item->get_name(); ?>', 'id': '<?php echo $item->get_product_id(); ?>', 'price': '<?php echo wc_get_price_excluding_tax($product); // OR wc_get_price_including_tax($product) ?>', 'category': '<?php echo $category; ?>', 'variant': '<?php echo $item->get_variation_id(); ?>', 'quantity': '<?php echo $item->get_quantity(); ?>' }, <?php endforeach ?> ] //expand this array if more product exists } } }); </script>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Conversion Tracking’ is closed to new replies.