Skip to content

How to Configure Ecommerce Tracking

There are two main stages for configuring ecommerce tracking within MVMCloud Analytics. In the first stage, you will need to make sure you have enabled ecommerce tracking in the MVMCloud Analytics interface. You can configure this in the site settings. Instructions follow below.

Stage One: Enabling Website Ecommerce Tracking

If you are already tracking a site within MVMCloud Analytics without ecommerce enabled, you will need to update your module settings. website to enable ecommerce tracking. Follow the steps below:

  1. Click the gear icon Gear Icon in the top menu to load the page of settings;
  2. In the left menu, click on Sites >> Manage;
  3. In the right-hand panel, choose which site you want to manage and click on the edit icon, as shown below; Manage measurables
  4. Scroll down the page until you reach the Ecommerce drop-down menu and select Ecommerce enabled;
  5. Select the appropriate Currency option from the drop-down menu below;
  6. Scroll down and press the Save button to complete the first stage of ecommerce tracking setup; Activate ECommerce
  7. To confirm that everything is working as expected, click the Control Panel link in the top menu. You should now see the Ecommerce menu item in the main navigation on the left side; Ecommerce activated

Stage Two: Enabling Tracking on Your Ecommerce Platform

The second step is to integrate the MVMCloud Analytics tracking code into your website. You can do this by adding the JavaScript codes required for your cart's custom code.

These codes must be added at specific points on your website, for example, the add to cart code must be added to the click the button to add to cart, the purchase code made can be added to the thank you page or purchase confirmation page of your website.

There are three categories of actions you will need to integrate for a complete ecommerce tracking setup:

  1. Order updates (required) – This is a mandatory component of ecommerce tracking.
  2. Product views (optional) – This allows you to calculate conversion rates by product.
  3. Cart Updates (Optional) – This allows you to track abandoned cart statistics.

Order Updates (Required)

Order tracking is the minimum configuration required for a successful ecommerce tracking implementation. Order metrics are probably the most valuable for any ecommerce store, so you need to make sure to configure order tracking correctly.

There are two main elements required to submit an ecommerce purchase to MVMCloud Analytics:

  • Product details for each product purchased, containing at least the product SKU (SKU is the product's stock code);
  • Order details, containing a unique order ID and minimum total revenue.

The order is usually tracked on the order confirmation page after payment has been confirmed.

Note: The unique order ID generated by the cart software ensures that the same order is not tracked twice.

Example of Adding a Product to the Order

The snippet below contains example data in the format required by MVMCloud Analytics. All parameters, which are shown in double quotes, must be filled in dynamically by your ecommerce platform.

  • productSKU (Required) – String – A unique product identifier;
  • productName (Recommended) – String – The name of the product;
  • productCategory (Optional) – String/Array – This is the category name passed as a string or up to five unique categories as an array, for example ["Books", "Launches", "Technology"];
  • price (Optional) – Integer/Float – The cost of the item;
  • quantity (Optional) – Integer – How many of this item are in the order. The default is 1.

Code example:


// Product Array
_paq.push(['addEcommerceItem',
     "01234567890", // (required) SKU: Unique product identifier
     "Ecommerce Metrics Book", // (optional) Product name
     "Books", // (optional) Product category. You can also enter an array with up to 5 categories. ex: ["Books", "Launches", "Biographies"]
     9.99, // (Recommended) Product selling price
     1 // (Optional - Default is 1) Quantity
]);

Ecommerce Order Tracking Example

The second part of the order update code passed to MVMCloud Analytics is a summary of the order. At a minimum, it should include an order ID and the total revenue amount. The variables passed, in order, are:

  • orderId (Required) – String – A unique reference number to avoid duplication.
  • grandTotal (required) – Integer/Float – The total order revenue including taxes and shipping with any discounts subtracted.
  • subTotal (Optional) – Integer/Float – The order total excluding shipping.
  • tax (Optional) – Integer/Float - The amount of tax charged.
  • shipping (Optional) – Full/Floating – The amount charged for shipping.
  • discount (Optional) – Integer/Float/Boolean – Discount offered? Defaults to false. Otherwise, you must include a numeric value.

Code example:


// Request Array - Parameters must be generated dynamically
_paq.push(['trackEcommerceOrder',
     "000123", // (Required) orderId
     10.99, // (Required) grandTotal (income)
     9.99, // (Optional) subTotal
     1.5, // (Optional) Tax
     1, // (Optional) Shipping
     false // (Optional) Discount
]);

Product Views (Optional)

By default, MVMCloud Analytics can tell you the conversion rate for your website as a whole. Additionally, you can track how many people have visited a page where your product is available for sale. Then MVMCloud Analytics will automatically calculate a conversion rate for each product.

Collecting product and category-specific conversion rates can be helpful in identifying where certain products may not have enough information or where specific product categories are underperforming on your site.

There is a JavaScript method to send product and category view data to MVMCloud Analytics, which is 'setEcommerceView'. The only difference between tracking products and categories is which parameters are attached to the call. For both, you will also need make sure to include a 'trackPageView' call. You can find more details and examples for both below.

Product Views

The following parameters are recommended for tracking product views:

  • productSKU (Required) – String – A unique product identifier.
  • productName (Required) – String – The name of the product.
  • categoryName (Optional) – String/Array – This is the category name passed as a string or up to five unique categories as an array, for example ["Books", "Releases", "Technologies"]
  • price (Optional) – Integer/Float – The cost of the item.

Example of product preview code


// Sending product preview data - Parameters must be generated dynamically
_paq.push(['setEcommerceView',
     "0123456789", // (Required) Product SKU code
     "Ecommerce Metrics Book", // (Optional) Product name
     "Books", // (Optional) Category name
     9.99 // (Optional) price
]);
// You should also call trackPageView when tracking product view
_paq.push(['trackPageView']);

Category Views

The following parameters are required and recommended for tracking page views for a category (not a product page)::

  • productSKU – Boolean – Must be equal to false.
  • productName – Boolean – Must be equal to false.
  • categoryName (Required) – String/Array – This is the category name passed as a string or up to five unique categories as an array, for example ["Books", "Releases", "Technologies"]

Example of category view code


// Sending category view data - Parameters must be generated dynamically
_paq.push(['setEcommerceView',
     false, // productName - Product name is not applicable for category view.
     false, // ProductSKU - Product stock code is not applicable for category view.
     "Books", // (Optional) Product category or array with up to 5 categories.
]);
// You must also call trackPageView when tracking category view
_paq.push(['trackPageView']);

Cart Updates (Optional)

To track cart additions and removals, your cart system will need to send the details of each item that remains in the cart after a user adds or removes an item, including those already submitted from previous Add clicks to cart. This is important to collect accurate information about the abandoned cart feature in MVMCloud Analytics. The data must be inserted within a “push”, which is the function that makes it possible to send structured data to MVMCloud Analytics via JavaScript. You will also need to provide the total value of all items in the cart. Therefore, the two elements required for cart tracking are:

  • An 'addEcommerceItem' push for each product currently in the cart, including the name and SKU at a minimum.
  • A final push 'trackEcommerceCartUpdate' with the cart total passed as a parameter.

Example of product cart update

Each item processed as part of the cart update can contain the following parameters, but must include, at a minimum, the name and SKU.

  • productSKU (Required) – String – A unique product identifier.
  • productName (Recommended) – String – The name of the product.
  • categoryName (Optional) – String/Array – This is the category name passed as a string or up to five unique categories as an array, for example ["Books", "Releases", "Technologies"]
  • price (Optional) – Integer/Float – The cost of the item.
  • quantity (Optional) – Integer – How many of this item are in the cart. The default is 1.

The snippet below contains example data in the format required by MVMCloud Analytics. All parameters must be filled dynamically by your ecommerce platform.


// A push addEcommerceItem must be generated for each item in the cart,
// even products not updated by the current "Add to Cart" click.
_paq.push(['addEcommerceItem',
     "0123456789", // (Required) productSKU
     "Ecommerce Metrics Book", // (Optional) productName
     ["Books", "Best Sellers"], // (Optional) productCategory
     9.99, // (Recommended) price
     1 // (Optional, default is 1) quantity
]);
// Pass the total value of the cart as a numeric parameter
_paq.push(['trackEcommerceCartUpdate', 15.5]);

Important Coin Notice

Currency variables must be passed as an integer or float.

The following currency parameters must be provided as integers or floats, not as strings:

  • Parameters for addEcommerceItem():
    • Price
  • Parameters for trackEcommerceOrder():
    • grand total (grandTotal)
    • subtotal
    • tax
    • freight
    • discount

For example, all the following values are not valid currency variables:

  • “5.3$”
  • “R$ 5.3”
  • “5.4”
  • “5.4”
  • “5.44”

The following values are valid currency variables:

*5 * 5.3 * 5.44

If your ecommerce software only provides the values as a string, you can call the Javascript function parseFloat() to convert the values into a valid format. First, make sure the string you want to work with does not contain symbols currency or other characters, for example, “554.30”. You can then pass this value through the function as shown:

parseFloat("554.30");

Note: The parseFloat() JavaScript function does not support comma-separated decimal values “25.3”, so this may be You need to replace the commas with periods first.

Other JavaScript Functions That May Be Useful

The following options can be especially useful when your ecommerce store is a single-page application:

  1. removeEcommerceItem(productSKU) – Removes a product from the order by SKU. You still need to call trackEcommerceCartUpdate to register the updated cart in MVMCloud Analytics;
  2. clearEcommerceCart() – Deletes the order completely. You still need to call trackEcommerceCartUpdate to register the updated cart in MVMCloud Analytics;
  3. getEcommerceItems() – Returns all items currently in the untracked ecommerce order. The returned array will be a copy, so changing it will not affect the ecommerce order. To affect what is tracked, use the methods: addEcommerceItem(), removeEcommerceItem(), clearEcommerceCart(). Useful for seeing the list of what will be tracked before tracking an order or cart update.

Complete List of JavaScript Functions

MVMCloud Analytics provides ecommerce analytics that let you measure items added to carts and learn detailed metrics about abandoned carts and purchase orders.

  • setEcommerceView( productSKU, productName, categoryName, price ) - Set the current page view to a product or category page view. When you call setEcommerceView must be followed by a call to trackPageView to register the product or category page view.
  • addEcommerceItem( productSKU, [productName], [productCategory], [price], [quantity] )- Add a product to the ecommerce order. It must be called for each product in the order.
  • removeEcommerceItem( productSKU ) - Remove the specified product from the untracked ecommerce order.
  • clearEcommerceCart()- Remove all products in untracked ecommerce order. _Note: This is done automatically after trackEcommerceOrder() is called.
  • getEcommerceItems() - Return all ecommerce items currently in the untracked ecommerce order. The returned array will be a copy, so changing it will not affect the ecommerce order. To affect what is tracked, use the addEcommerceItem()// methods. Use this method to see what will be tracked before tracking an order or cart update.removeEcommerceItem()clearEcommerceCart()
  • trackEcommerceCartUpdate( grandTotal ) - Track a shopping cart. Call this javascript function every time a user is adding, updating or deleting a product from the cart.
  • trackEcommerceOrder( orderId, grandTotal, [subTotal], [tax], [shipping], [discount] ) - Track an ecommerce order, including any ecommerce items previously added to the order. orderIde grandTotal(i.e. revenue) are required parameters.