Ecommerce Edit the file on GitHub

Ecommerce tracking allows you to measure the transactions and revenue generated from your e-shop.

You can track two types of ecommerce data:

Order
A completed order - transaction
Item
An item of a completed order - transaction
Table of Contents

Ecommerce

addOrder

The addOrder command creates an Ecommerce order object.

Data Parameters
Name Type Required Description
order_id String Yes The Order ID that was produced by your e-shop. It is used to uniquely identify the transaction.
revenue String Yes The total revenue or grand total of the order. This value must include shipping and tax costs. Any additional payment cost should be excluded.
shipping String Yes The total shipping cost of the order. Any additional payment cost should be excluded.
tax String Yes The total tax of the order.
Note

Make sure not to include any spot cash costs in either revenue or shipping.

Example
<script>
  sa('ecommerce', 'addOrder', JSON.stringify({
    order_id: '123456',   // Order ID. Required.
    revenue:  '1315.25',  // Grand Total. Includes Tax and Shipping. Does not include payment costs.
    shipping: '5.45',     // Total Shipping Cost. Does not include payment costs.
    tax:      '301.25'    // Total Tax.
  }));
</script>

addItem

The addItem command adds a new Ecommerce item object.

Data Parameters
Name Type Required Description
order_id String Yes The Order ID that was produced by your e-shop. This ID links items to their orders.
product_id String Yes The Unique ID from your e-shop.
name String Yes The name of the product from your e-shop.
price String Yes The individual, unit, final price for each item.
quantity String Yes The number of units purchased in the order.
Note
  1. As the Product ID you must provide the same Unique ID that is submitted as part of the XML feedspec.
  2. The name of the product must match the Name that is submitted as part of the XML feedspec.
  3. Make sure your Order ID in your addItem command matches the one submitted by addOrder.
Example
<script>
  sa('ecommerce', 'addItem', JSON.stringify({
    order_id:   '123456',                                    // Order ID. Required.
    product_id: '111222',                                    // Product ID. Required.
    name:       'Apple IPhone 6 Plus (16GB) Space Gray EU',  // Product Name. Required.
    price:      '654.90',                                    // Price per Unit. Required.
    quantity:   '2'                                          // Quantity of Items. Required.
  }));
</script>