X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   X-Payments issues & questions (https://forum.x-cart.com/forumdisplay.php?f=50)
-   -   X-Payments with Google Analytics Conversion Code (https://forum.x-cart.com/showthread.php?t=66792)

ambal 01-06-2015 12:34 AM

Re: X-Payments with Google Analytics Conversion Code
 
The solution from the forum actually works in your store. However, the tracking code was not displayed because of the templates cache. We've cleaned the cache up, and as far as we can see, now the Google Analytics, BazaarVoice and some other tracking code is included into the invoice page correctly. Please check it from your side.

You may find the information regarding the X-Cart templates cache here: http://help.x-cart.com/index.php?title=X-Cart:Advanced_Tools#Clear_Templates.2FX-Cart_Cache

mcanitano 01-30-2015 08:28 AM

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

Code:

<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','//www.google-analytics.com/analytics.js','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': '{$order.order.total}',                                            // Grand Total
    {if $order.order.shipping_cost gt 0}'shipping': '{$order.order.shipping_cost}'{else}'shipping': '0'{/if},                    // Shipping
    {if $order.order.tax gt 0}'tax': '{$order.order.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}://checkout.google.com/files/digital/ga_post.js" type="text/javascript"></script>
{/if}



All times are GMT -8. The time now is 10:29 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.