Order tracking script
Overview
Add custom JavaScript code to the last stage of the ordering process (the Thank You page). This area can be used to add a monitoring script, such as Google Analytics, for advanced tracking of your sales, visitors, and customer conversion rates. Scripts supported are not limited to Google Analytics, and you can also include Google AdSense code.
Web Analytics platforms offer information on visitor traffic trends for your web properties. Using this tool, you can integrate your Google Analytics account with your shopping cart and extract relevant information such as behavior and transaction statistics.
Availability
Tracking scripts for the desktop version of the shopping cart are available to all 2Checkout accounts.
The tracking script is included in the Thank You page (finish.php) displayed to customers only after they successfully place an order:
Payment needs to be authorized successfully. This usually happens for online payment methods that are authorized instantaneously, such as credit/debit cards and PayPal.
Payment needs to go through without any problems or errors.
Set up tracking scripts
The tracking script is included in the Thank You page (finish.php) displayed to customers only after they successfully place an order:
Payment needs to be authorized successfully. This usually happens for online payment methods that are authorized instantaneously, such as credit/debit cards and PayPal.
Payment needs to go through without any problems or errors.
To set up tracking scripts, follow these steps:
Log in to Control Panel.
Go to Setup -> Ordering Options -> Analytics.
Select the type of platform (cart) you want to include the tracking code on.
You can use HTML formatting and tags and edit the code directly.
Define tracking scripts for specific or all languages available for your account. You will be able to track visitors and sales according to the cart language selected, either automatically, by the 2Checkout system through its geo-location capabilities, or manually by the shoppers. If the tracking script isn't included for a certain language, you will not be able to track successful orders for customers using that language in the cart. Use the Apply for all languages option to set the same script for all languages available for your account.
To change scripts, you need to edit each item. Selecting the Apply for all languages option will overwrite all existing scripts with the latest version you supply.
Click Save tracking script to save a new script or any edits.
SSl Protocol
Use the SSL protocol when including external scripts (e.g. Google Analytics) or images:
<script src="https://www.google-analytics.com/analytics.js" type="text/javascript">
<img src="https://www.2checkout.com/resources/en/general/1x1.gif" alt="" border="0">
A JS object called myOrder is available on the Thank You page providing information about the purchased products, including ID, quantity, name, price, etc.
Use the tracking script for all orders
By default, the after-sale message is displayed only for orders with payments authorized instantly (usually, credit cards and PayPal), after the payment is complete (the transaction needs to be authorized successfully). To display the message for all placed orders regardless of the payment status:
Go to Setup -> Ordering Options.
Scroll down to the bottom of the Order settings area and check the checkbox for the Show message for all placed orders option.
Click Save Settings.
The message will be displayed even for orders where the payment is not yet received (like bank transfers or checks).
Tracking script example
myOrder object
In addition to the custom JavaScript code that you can add to the last page of the purchase process (Thank You page - finish.php), 2Checkout also provides a JS object labeled myOrder.
productsInOrder
Array
An array containing all order products. Every array element is a JavaScript object with the following properties:
id
String
Unique system-generated product ID.
name
String
Product name.
quantity
Int
The number of product units added to cart.
code
String
Editable product code that you control
price
Float
Product price.
priceUSD
Float
Product price in USD.
priceEUR
Float
Product price in EUR.
category
String
Product category.
coupon
String
Promotion code used for the product.
discount
Float
Value of the customer discount for the product expressed in the currency used for the order.
discountEUR
Float
Value of the customer discount for the product expressed in EUR.
discountUSD
Float
Value of the customer discount for the product expressed in USD.
pricingOptions
String
Selection of product pricing options added to cart.
purchaseType
String
Product purchase type:
· REGULAR
· TRIAL
· RENEWAL
· UPGRADE
productVersion
String
Product version.
promotion
String
Marketing campaign/promotion name of the product.
productsIds
Array
Array with the IDs of the products in the cart.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system and feature standalone IDs.
productsQuantities
Array
Array with the number of units of products added to the cart.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system and feature quantity (1).
productsNames
Array
Array with the names of the products added to the cart.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system. productNames will feature the promotion title.
productsCodes
Array
Array with the codes of the products added to the cart.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system and feature standalone codes.
productsPrices
Array
Array with the prices (expressed in the currency selected for the order) of the products added to cart.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system and have negative values equal to the amount of the discount which gets deducted from the total order value.
productsPricesUSD
Array
Array with the prices (expressed in the USD) of the products added to the cart.
productsPricesEUR
Array
Array with the prices (expressed in the EUR) of the products added to the cart.
productsNumber
Int
The number of distinct products added to the cart.
productsPromotionsCoupons
Array
Array with promotion coupons impacting products added to cart.
refNo
Int
Unique, system-generated order reference number.
externRefNo
String
The order external reference number.
idAffiliate
Int
The affiliate ID referring products in the order (0 if the order was not referred by an affiliate).
AFFSRC
String
Affiliate source (SRC) parameter. NULL if no Affiliate SRC is used for an order.
totalPrice
Float
Total order value (in the currency selected for the order).
totalPriceUSD
Float
Total order value (in USD).
totalPriceEUR
Float
Total order value (in EUR).
discount
Float
Value of coupon discount expressed in the currency selected for the order.
Order promotions (non-coupon discounts) are similar to products in the 2Checkout system and the discounted value is not included under discount.
discountUSD
Float
Value of coupon discount expressed in USD.
discountEUR
Float
Value of coupon discount expressed in EUR.
affiliateCommission
Float
Value of the affiliate commission for the order (expressed in the currency selected for the order).
affiliateCommissionUSD
Float
Value of the affiliate commission for the order (in USD).
affiliateCommissionEUR
Float
Value of the affiliate commission for the order (in EUR).
tax
Float
Value of sales tax or VAT (for EU) expressed in the currency selected for the order.
taxUSD
Float
Value of sales tax or VAT (for EU). (in USD)
taxEUR
Float
Value of sales tax or VAT (for EU). (in EUR)
shipping
Float
Shipping costs expressed in the currency selected for the order.
shippingUSD
Float
Shipping costs expressed in USD.
shippingEUR
Float
Shipping costs expressed in EUR.
currency
String
The currency selected for the order (ISO 4217 code; e.g.: EUR, USD, AUD, CAD).
city
String
Shopper city from the billing details.
state
String
Shopper state from the billing details.
Country
String
Shopper country code (ISO 3166; e.g.: US, CA, AU, FR, DE) from the billing details.
zipCode
String
Shopper country zip code from the billing.
avangateCustomerId
Int
Unique customer ID generated by 2Checkout for subscriptions sold. 2Checkout populates the value of the customer identifier only if you use the CUSTOMERID query parameter in your Buy Links.
externalCustomerId
String
Customer ID you control for subscriptions sold. 2Checkout populates the value of the customer identifier only if you use the CUSTOMERID query parameter in your Buy Links.
FAQ
Is there a way to bypass the Thank You page?
Yes. If you use a Redirect URL when generating Buy Links, i.e. including the BACK_REF parameter in Buy Links together with a specific URL where shoppers are redirected after placing the order. Note: Shoppers will be redirected to this URL after the payment is confirmed. The redirect URL replaces the default "Thank you" page (except for offline payment methods such as Bank Transfer).
Last updated
Was this helpful?