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

Conversion Tracking

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-07-2015, 03:42 AM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Conversion Tracking

Hi,
I have found a code in order to track sale but cannot able to add it in x-cart page.
This is the code they have supplied-
Copy first code snippet and paste it in the footer section of your template.
HTML Code:
<script type="text/javascript">var showButton = true;</script> <script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script> <script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script>

and Copy second code snippet and paste it in the footer of your checkout page.
HTML Code:
<script type="text/javascript">var showButton = false;</script> <script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script> <script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script> <script type="text/javascript"> var customer_name = "CUSTOMER_NAME"; // Replace CUSTOMER_NAME with the customer name var customer_email = "CUSTOMER_EMAIL"; // Replace CUSTOMER_NAME with the customer email var grandTotal = "GRAND_TOTAL"; // Replace GRAND_TOTAL with the total amount of the bill of customer var subTotal = "SUBTOTAL"; // Replace SUBTOTAL with the subtotal amount of the bill of customer var couponCode = "COUPON_CODE"; // Replace COUPON_CODE with the coupon code applied by customer. Leave it blank if no coupon code is applied. var order_id = "ORDER_ID"; // Optional var currency = "CURRENCY"; //Optional // Push all products to refiral_cart_items array var refiral_cart_items = []; refiral_cart_items.push({ product_id: "P1", // Product ID quantity: "2", // Quantity name: "Product 1", // Name of product }); refiral_cart_items.push({ product_id: "P2", // Item Product ID quantity: "1", // Item Quantity name: "Product 2", // Name of product }); invoiceRefiral(subTotal, grandTotal, couponCode, refiral_cart_items, customer_name, customer_email, order_id, currency); </script>

Now please suggest me where to add.

Thanks,
xtech
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
  #2  
Old 04-08-2015, 09:37 PM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Re: Conversion Tracking

Can anyone help me please?
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
  #3  
Old 04-08-2015, 11:08 PM
 
Stur Stur is offline
 

Advanced Member
  
Join Date: Jan 2015
Posts: 30
 

Default Re: Conversion Tracking

Unfortunately I'm not familiar with xcart 4 but is there a "Look & Feel" section where you can input custom javascript, like there is with Xcart5?
__________________
X-Cart 5
Antifraud
Template #42
Reply With Quote
  #4  
Old 04-08-2015, 11:46 PM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Re: Conversion Tracking

I have added the second set of code in reboot/customer/main/order_message.tpl

HTML Code:
{foreach from=$orders item=order} {literal}<script type="text/javascript">var showButton = false;</script>{/literal} {literal}<script type="text/javascript">var apiKey = "169779d3852b32ce8b1a1724dbf5217d";</script>{/literal} {literal}<script type="text/javascript" src="//cdn.refiral.com/libs/refiral-1.0.min.js"></script>{/literal} {literal}<script type="text/javascript"> var customer_name ='{$order.s_firstname|escape}&nbsp;{$order.s_lastname|escape}'; // Replace CUSTOMER_NAME with the customer name var customer_email ='{$order.order.email}'; // Replace CUSTOMER_NAME with the customer email var grandTotal = '{$order.order.total}'; // Replace GRAND_TOTAL with the total amount of the bill of customer var subTotal = '{$order.order.display_subtotal}'; // Replace SUBTOTAL with the subtotal amount of the bill of customer var couponCode = '{$order.order.coupon}'; // Replace COUPON_CODE with the coupon code applied by customer. Leave it blank if no coupon code is applied. var order_id = '{$order.order.orderid}'; // Optional var currency = INR; //Optional // Push all products to refiral_cart_items array var refiral_cart_items = []; refiral_cart_items.push({ product_id: '{$product.productid}', // Product ID quantity: '{$product.amount}', // Quantity name: '{$product.product}', // Name of product }); refiral_cart_items.push({ product_id: '{$product.productid}', // Item Product ID quantity: '{$product.amount}', // Item Quantity name: '{$product.product}', // Name of product }); invoiceRefiral(subTotal, grandTotal, couponCode, refiral_cart_items, customer_name, customer_email, order_id, currency); </script> {/literal} {/foreach}

But it is not working.I want anyone's help in forum.

Thanks.
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
  #5  
Old 04-16-2015, 06:07 AM
  mcanitano's Avatar 
mcanitano mcanitano is offline
 

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

Default Re: Conversion Tracking

well for one, it looks like you have Smarty variables inside literal tags, that is why they aren't populating.

See

http://www.smarty.net/docsv2/en/language.function.literal

http://www.smarty.net/docsv2/en/language.function.ldelim.tpl

Basically when you use {literal} the smarty variables do not work. So you must {/literal}{$smarty.variable}{literal} each time

This is a quick google search on using smarty variables inside literal tags.

http://stackoverflow.com/questions/5001886/how-can-a-smarty-variable-be-made-working-under-literal-literal


As far as your foreach loop. I believe you need a second foreach loop for the products.


You should have one (like you do) for orders, and a separate for the products inside the orders to get variables like {$product.productid}

Try using
Code:
{foreach from=$order.products item="product"} // Push all products to refiral_cart_items array var refiral_cart_items = []; refiral_cart_items.push({ product_id: '{$product.productid}', // Product ID quantity: '{$product.amount}', // Quantity name: '{$product.product}', // Name of product }); refiral_cart_items.push({ product_id: '{$product.productid}', // Item Product ID quantity: '{$product.amount}', // Item Quantity name: '{$product.product}', // Name of product }); {/foreach}
__________________
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
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


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 04:36 AM.

   

 
X-Cart forums © 2001-2020