View Single Post
Old 01-30-2015, 08:28 AM
  mcanitano's Avatar 
mcanitano mcanitano is offline

Join Date: Feb 2006
Location: Melbourne, FL
Posts: 216

Default Re: X-Payments with Google Analytics Conversion Code

We had this same issue, and removed the ga_track_commerce eq "y" in the {if} statement in ga_code_async.tpl. (put it in //comments so we still have the original code)

See our code below, we're 99% sure it's working as it should

<script type="text/javascript"> (function(i,s,o,g,r,a,m){ldelim}i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ldelim} (i[r].q=i[r].q||[]).push(arguments){rdelim},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) {rdelim})(window,document,'script','//','ga'); ga('create', '{$config.Google_Analytics.ganalytics_code}'); // Analytics Property ID ga('require', 'linkid', 'linkid.js'); ga('send', 'pageview'); {if $config.Google_Analytics.ganalytics_e_commerce_analysis eq "Y" and $main eq "order_message" and $orders } // and $ga_track_commerce eq "Y" // Ecommerce Tracking for order_message page ga('require', 'ecommerce'); // Load the ecommerce plug-in. ga('require', 'ecommerce', 'ecommerce.js'); {foreach from=$orders item="order"} ga('ecommerce:addTransaction', {ldelim} 'id': '{$order.order.orderid}', // Transaction ID. Required 'revenue': '{$}', // Grand Total {if $order.order.shipping_cost gt 0}'shipping': '{$order.order.shipping_cost}'{else}'shipping': '0'{/if}, // Shipping {if $ gt 0}'tax': '{$}',{/if} // Tax 'affiliation': '{$partner|default:'SilverHorse Racing'}' // Affiliation or store name {rdelim}); {foreach from=$order.products item="product"} ga('ecommerce:addItem', {ldelim} 'id': '{$order.order.orderid}', // Transaction ID. Required. 'name': '{$product.product|wm_remove|escape:javascript}{if $active_modules.Product_Options ne "" and $product.product_options_txt} ({$product.product_options_txt|replace:"\n":", "|wm_remove|escape:javascript}){/if}', // Product name. Required. 'sku': '{$product.productcode|wm_remove|escape:javascript}', // SKU/code. 'category': '{$product.category|default:'Unknown category'}', // Category or variation. 'price': '{$product.price}', // Unit price. 'quantity': '{$product.amount}' // Quantity. {rdelim}); {/foreach} {/foreach} ga('ecommerce:send'); //submits transaction to the Analytics servers {/if} </script> {if $active_modules.Google_Checkout ne ""} <script src="{if $current_location eq $http_location}http{else}https{/if}://" type="text/javascript"></script> {/if}
Marcello Canitano
New Site: X-Cart v4.5.5 GOLD
X-Cart Mobile v1.4.3
X-Payments v1.0.6
CDSEO Pro v2
Total Server Solutions xCDN
Reply With Quote