Egoimmerce Analytics Documentation


Ecommerce tracking

Once you have enabled Ecommerce tracking for a website, you need to implement tracking of the various Ecommerce interactions on your website. There are three main Ecommerce interactions that are tracked with Egoimmerce:

  • Ecommerce Orders (and products)
  • Ecommerce Cart update (and products)
  • Product (and/or category) page views

The following sections explain how to set up Ecommerce tracking, using the JavaScript Tracker Ecommerce tracking methods

Tracking Ecommerce Orders & Items Purchased (required)

Tracking Ecommerce orders and product details will allow Egoimmerce to process reports on:

  • Product SKU
  • Product name
  • Top Product categories and general overview of Ecommerce performance in your online shop

To track Ecommerce orders, two Javascript functions are used:

  1. addEcommerceItem(productSKU, productName, productCategory, price, quantity) This adds a product into the order, and must be called for each product in the order. productSKU is a required parameter, it is also recommended that you send other parameters if they are applicable in your Ecommerce shop.
  2. trackEcommerceOrder(orderId, grandTotal, subTotal, tax, shipping, discount) This tracks an Ecommerce order and sends the data to your Egoimmerce server, for both this order and products previously added. Only orderId and grandTotal (ie. revenue) are required.

Here’s an example of tracking an Ecommerce order containing two products – this code should be inserted in the “Order confirmation” page, once the visitor has checked out and issued payment. If you installed Egoimmerce correctly, your pages should already have a tracking code. The Ecommerce code below must be added and generated based on the Order:

// add the first product to the order
_egoiaq.push(['addEcommerceItem',
    "9780786706211", // (required) SKU: Product unique identifier
    "Endurance: Shackleton's Incredible Voyage", // (optional) Product name
    "Adventure Books", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
    8.8, // (recommended) Product price
    1 // (optional, default to 1) Product quantity
]);
// Here you can add other products in the order
[...]
// Specifiy the order details to Egoimmerce server & sends the data to Egoimmerce server
_egoiaq.push(['trackEcommerceOrder',
    "A10000123", // (required) Unique Order ID
    35, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
    30, // (optional) Order sub total (excludes shipping)
    5.5, // (optional) Tax amount
    4.5, // (optional) Shipping amount
    false // (optional) Discount offered (set to false for unspecified parameter)
]);
// we recommend to leave the call to trackPageView() on the Order confirmation page
_egoiaq.push(['trackPageView']);

Important notes about the functions parameters:

  • price (parameter of addEcommerceItem() function), grandTotal, subTotal, tax, shipping, discount (parameters of trackEcommerceOrder() function) must be supplied as integer or floats, not as string. For example, all the following values are not valid: “14.4$”, “EUR14.4″, “14,4″, “14.4″. The following values are valid: 5,3.3, 5.44. If your Ecommerce software provides the values as string only, you can call the Javascript function parseFloat() after making sure the string does not contain currency symbol or other characters, for example: parseFloat(“554.20″). Note that the Javascript parseFloat() does not support comma separated decimal values “25,3″ so you might have to replace the commas with dots before calling parseFloat().
  • orderId parameter is a unique string identifier for the order. If the page containing the trackEcommerceOrder() call is refreshed by the customer a few hours or days after the initial Order, Egoimmerce will automatically discard the order as it is already recorded. You can use the same orderId for different Websites id, but for a given website, orderId must be unique.
  • If you print out some of these parameters in the HTML code, make sure that the Product SKUs, Names and categories are escaped in particular the ” character (double quotes), otherwise it may create Javascript parse errors.

Tracking Add to Cart & Items Added to the Cart (optional)

Every time a visitor adds (or updates, deletes) an item from his/her cart, you can use Egoimmerce to track the latest cart subtotal as well as products left in the cart. Tracking cart updates will allow you to see how much revenue was left in your visitors’ carts for each day/week/etc, as well as getting reports on which products are most often left in the cart and which product categories are most often left abandoned in carts.

Some frequent causes for cart abandonment are:

  • high shipping prices,
  • complicated forms for new users (lack of “Anonymous checkout” option),
  • complicated / lengthy checkout process,
  • slow website,
  • visitor was just browsing the site or wanted to compare total cost with competitor.

When you make changes to your website to lower the cart abandonment rate, and try to increase your revenues, you can use Egoimmerce to understand if your changes are making a positive impact.

To track Shopping Carts with Egoimmerce, you would call the javascript function trackEcommerceCartUpdate() every time a user is adding, updating or deleting a product from the cart.

Example tracking an Ecommerce order containing two products:

The code is added every time the “cart” page is loaded, or when the “Add to cart” button is clicked:

// add the first product to the order
_egoiaq.push(['addEcommerceItem',
    "9780786706211", // (required) SKU: Product unique identifier
    "Endurance: Shackleton's Incredible Voyage", // (optional) Product name
    ["Adventure Books", "Best sellers"], // (optional) Product category, string or array of up to 5 categories
    8.8, // (recommended) Product price
    1 // (optional, default to 1) Product quantity
]);

// Here it is important to add all other products found in the cart, even the products not updated by the current "Add to cart" click
[...]

// Records the cart for this visit
_egoiaq.push(['trackEcommerceCartUpdate',
    15.5]); // (recommended) Cart amount

_egoiaq.push(['trackPageView']);

Tracking Product Page Views & Category Page Views (optional)

Tracking product page views, and/or category page views lets Egoimmerce process the conversion rate for each product and/or category. It can be useful to know which product or category pages have converted your visitors into customers. For example, perhaps some product pages have below average conversion rates but generate high revenue. You may decide to improve these product pages and check their conversion rates over time.

To track a product or category page view, the function setEcommerceView(productSKU, productName, categoryName, price) is used, just before the call to egoimmerceTracker.trackPageView() on the product/category page.

Example Tracking a Product Page View

In this example, the following code is added to the Product page for the book “Endurance” which is in the category “Adventure Books”:

// all parameters are optional, but we recommend to set at minimum productSKU and productName
_egoiaq.push(['setEcommerceView',
    "9780786706211", // (required) SKU: Product unique identifier
    "Endurance: Shackleton's Incredible Voyage", // (optional) Product name
    "Adventure Books", // (optional) Product category, or array of up to 5 categories
    20.11 // (optional) Product Price as displayed on the page
]);
_egoiaq.push(['trackPageView']);

Example tracking a Category page view

This code is added on the Category page “Adventure Books”

// on a category page, productSKU and productName are not applicable and are set to false
_egoiaq.push(['setEcommerceView',
    productSku = false, // No product on Category page
    productName = false, // No product on Category page
    category = "Adventure Books" // Category Page, or array of up to 5 categories
]);
_egoiaq.push(['trackPageView']);