Title: Conversion Tracking
Last modified: September 30, 2020

---

# Conversion Tracking

 *  Resolved [stefk](https://wordpress.org/support/users/stefk/)
 * (@stefk)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/conversion-tracking-16/)
 * 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)

 *  Plugin Author [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * (@oscargare)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/conversion-tracking-16/#post-13486658)
 * Hi,
    [$order->get_currency()](https://woocommerce.github.io/code-reference/classes/WC-Abstract-Order.html#method_get_currency)
   returns the order currency.

Viewing 1 replies (of 1 total)

The topic ‘Conversion Tracking’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-product-price-based-on-countries/assets/icon-
   256x256.png?rev=1976858)
 * [Price Based on Country for WooCommerce](https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/reviews/)

## Tags

 * [currency](https://wordpress.org/support/topic-tag/currency/)
 * [tracking](https://wordpress.org/support/topic-tag/tracking/)

 * 1 reply
 * 2 participants
 * Last reply from: [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/conversion-tracking-16/#post-13486658)
 * Status: resolved