Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Let's Talk AdWords: How to Install the AdWords Conversion Tracking Code in X-Cart
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #51  
Old 07-25-2014, 05:55 AM
  mcanitano's Avatar 
mcanitano mcanitano is offline
 

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

Default Re: Let's Talk AdWords: How to Install the AdWords Conversion Tracking Code in X-Cart

We are pretty positive we have come up with a solution that will work with x-cart v4.5.x (we are on v4.5.5)


For using Adwords Conversions:

First create your Conversion in Adwords Conversion Tracking. Make it a purchase/sale and set the conversion value to "Each conversion has a different value. If there's no value, use 1" and make sure to track All Conversions.

We have signed up to use Google Tag Manager since it is very easy to have all of your analytics in one program.
We also use "Google Tag Assistant" extension in google chrome, so we can verify all of our code is working.

Sign up for Google Tag Manager, and create a Tag for Adwords Conversion Tracking (see attached photo).

Then create a Macro that will allow you to track the total price (see second attached photo).

In order for the macro (and your google tag manager) to work, we implemented the following code.




In the "/common_files/customer/home.tpl" file directly after the opening <body> tag:


Code:
{foreach from=$orders item="order"} <script> {literal} dataLayer = [{ 'transactionTotal': {/literal}{$order.order.total}{literal} }];{/literal} </script> {/foreach}

This is our personal code for google tag manager, use your own code by going to Admin->Install GTM in the Google Tag Manager website


This code goes directly below the above Macro code in "/common_files/customer/home.tpl"

Code:
<!-- Google Tag Manager --> <noscript> <iframe src="//www.googletagmanager.com/ns.html?id=GTM-GVNVT" height="0" width="0" style="display:none;visibility:hidden"> </iframe> </noscript> {literal} <script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-GVNVT'); </script> <!-- End Google Tag Manager --> {/literal}



If you'd like to use google analytics, this is the code in our "/common_files/modules/Google_Analytics/ga_code_async.tpl" file that is working for us. You can also simply use the Google Analytics tag in Google Tag Manager (recommended):


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 } // we removed from the above if statement $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}
Attached Thumbnails
Click image for larger version

Name:	adwords tag manager.png
Views:	52
Size:	25.6 KB
ID:	3843  Click image for larger version

Name:	macro.png
Views:	40
Size:	31.0 KB
ID:	3844  
__________________
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

www.silverhorseracing.com
Reply With Quote
  #52  
Old 02-03-2016, 08:37 PM
 
yari yari is offline
 

Newbie
  
Join Date: Feb 2016
Posts: 8
 

Question Re: Let's Talk AdWords: How to Install the AdWords Conversion Tracking Code in X-Cart

Hi!

I know this is an old thread, but this is still not very straightforward with xCart. Unfortunately, the links you reference, no longer point to the right sources showing the steps. Can anyone share the code or A code that works for version 5.2.12?

Thanks!
__________________
yari
Reply With Quote
  #53  
Old 05-26-2016, 12:48 PM
 
paulmighty paulmighty is offline
 

Member
  
Join Date: Apr 2014
Posts: 11
 

Default Re: Let's Talk AdWords: How to Install the AdWords Conversion Tracking Code in X-Cart

Quote:
Originally Posted by yari
Hi!

I know this is an old thread, but this is still not very straightforward with xCart. Unfortunately, the links you reference, no longer point to the right sources showing the steps. Can anyone share the code or A code that works for version 5.2.12?

Thanks!

Hi Yari, would be interested in hearing about your experience integrating GTM. There is this page in the documentation:
http://kb.x-cart.com/pages/viewpage.action?pageId=9307079
__________________
X-Cart Version: 5.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2018