Skip to main content
knowledgecenter.avangate.com

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, visitor 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

  1. Tracking scripts for the desktop version of the shopping cart are available to all Avangate accounts.
  2. Setting tracking scripts for mobile users requires an account with the Avangate mobile shopping cart activated. Please contact Avangate directly.

At which stage of the ordering process is the tracking script included?

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.

How do I set up tracking scripts?

  1. Go toSetup-> Ordering Options -> Tracking Script.
  2. Select the type of platform (cart) you want to include the tracking code on. Note: The tracking code needs to be included for each platform separately.
    • Desktop
    • Mobile 
  3. You can use HTML formatting and tags and edit the code directly.
  4. Define tracking scripts for specific or for 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 Avangate system through its geo-location capabilities, or manually by the shoppers. If 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.
  5. To change scripts, you need to edit each item in part. Selecting the Apply for all languages option will overwrite all existing scripts with the latest version you supply.
  6. Click Save tracking script to save a new script or any edits.

Best practices

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.avangate.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 (this includes usually credit cards and PayPal), after the payment is complete (transaction needs to be authorized successfully). To display the message for all placed orders regardless of the payment status:

  1. Go to Setup -> Ordering Options.
  2. Scroll down to the bottom of the Order settings area and check the checkbox for the Show message for all placed orders option.
  3. 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

<!-- Google Code for purchase Conversion Page -->
<script language="JavaScript" type="text/javascript">
<!--
var google_conversion_id = 9999999999;
var google_conversion_language = "en_US";
var google_conversion_format = "1";
var google_conversion_color = "FFFFFF";
if (25.0) {var google_conversion_value = 25.0;}
var google_conversion_label = "purchase";
//-->
</script>
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0
src="https://www.googleadservices.com/pag...chase&script=0">
</noscript>

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), Avangate also provides a JS object labeled myOrder.

 

productsInOrder

Array

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

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 Avangate system and feature standalone IDs.

productsQuantities

Array

Array with the number of units of products added to cart.

 

Order promotions (non-coupon discounts) are similar to products in the Avangate system and feature quantity (1).

productsNames

Array

Array with the names of the products added to cart.

 

Order promotions (non-coupon discounts) are similar to products in the Avangate system. productNames will feature the promotion title.

productsCodes

Array

Array with the codes of the products added to cart.

 

Order promotions (non-coupon discounts) are similar to products in the Avangate 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 Avangate 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 cart.

productsPricesEUR

Array

Array with the prices (expressed in the EUR) of the products added to cart.

productsNumber

Int

The number of distinct products added to 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 Avangate 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 Avangate for subscriptions sold. Avangate populates the value of the customer identifier only of you use the CUSTOMERID query parameter in your Buy Links.

externalCustomerId

String

Customer ID you control for subscriptions sold. Avangate populates the value of the customer identifier only of you use the CUSTOMERID query parameter in your Buy Links.

FAQ

  1. 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).