PIWIK - Ecommerce Analytics & Segmentation

Ecommerce Analytics

Ecommerce Analytics – Piwik Docs
Piwik analytics – Odoo Apps

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 Piwik:

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

Tracking Ecommerce Orders & Items Purchased (required)

Tracking Ecommerce orders and product details will allow Piwik 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 Piwik 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. The Ecommerce code below must be added and generated based on the Order:

[...]
// add the first product to the order
_paq.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 Piwik server & sends the data to Piwik server
_paq.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
_paq.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″).

  • 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, Piwik 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.

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 Piwik 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. Also, you can visualize each visit and the content of the cart they abandoned in the Visitor Log.

Some frequent causes for cart abandonment are:

??

To track Shopping Carts with Piwik, 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:

[...]
// add the first product to the order
_paq.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
_paq.push([
  'trackEcommerceCartUpdate',
  15.5]); // (required) Cart amount
_paq.push(['trackPageView']);
[...]

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

Tracking Product Page Views & Category Page Views (optional)

To track a product or category page view, the function setEcommerceView(productSKU, productName, categoryName, price) is used, just before the call to 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
_paq.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
]);
_paq.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
_paq.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
]);
_paq.push(['trackPageView']);
[...]

Check out the full documentation and example links at: Ecommerce Analytics API Reference


Segmentation – Useful segments you can create

Custom segment: Customers

See everyone who bought something from you.

Visit Ecommerce status at the end of the visit is ordered OR Visit Ecommerce status at the end of the visit is orderedThenAbandonedCart

Questions to ask yourself
What did everyone who bought something from you buy?
Did they come back or did they buy something and leave forever?
What did they do before they bought something?

Custom segment: Returning customers

See everyone who bought something and then came back for more.

Visit Ecommerce status at the end of the visit is ordered AND Number of Visits is greater than 1

Questions to ask yourself
What did everyone who bought something and came back look for?
Did they find it and buy it? Or did they leave empty handed?
If they left, did they come back or did they leave forever?

Custom segment: Bounced visits

See everyone who visited your website and immediately left.

Number of Actions equals 1

Questions to ask yourself
What pages are these visitors visiting?
What keywords were they using?
Why do you think those pages didn’t answer their questions?

Custom segment: Everyone who doesn’t bounce

See everyone who visited your website and stuck around.

Number of Actions is greater than 1

Questions to ask yourself
What do people who stick around on your website look for?
How do they get to your website?
Are they looking for something your website doesn’t provide?
Use your imagination, stay curious and you’ll stumble upon insights that will help you prosper.

Custom segment: Mobile visitors

See everyone who accessed your website from a mobile device. Note: to access this segment, first enable the “DevicesDetection” plugin.

Device type is smartphone OR Device type is tablet OR Device type is feature phone

Questions to ask yourself
Do you get a lot of visitors from mobile devices?
Can they successfully navigate and use your website?
What pages don’t they visit or spend much time on?

Custom segment: Visits from the region your business is located in

See everyone who accessed your website from certain region.

Country is xx AND Region is xx

Questions to ask yourself
Do you get a lot of visitors near your business?
What information do they look for on your website?

Custom segment: Commenters

See everyone who commented on your website. Note: This segment depends first on setting up a Custom Variable commenter_id.

Custom Variable name 1 (scope visit) is commenter_id

Written on February 24, 2016