matomo
ecommerce tracking

Matomo

https://matomo.org/docs/ecommerce-analytics/  
 

What is the Value of Ecommerce Tracking?

Enabling Ecommerce tracking in Matomo allows you to go far beyond just merely tracking how much money is coming into your bank account. Within Matomo’s Ecommerce reporting features, you can discover the specific website actions and traffic sources that lead to sales. This can help you optimise your website and marketing campaigns to increase your profitability. Linking your analytics with ecommerce reporting can also help you catch issues. For example, you’ll be able to notice that a certain browser isn’t making sales due to website errors. Or perhaps you’ve been paying a lead source to receive thousands of visits, but ecommerce tracking reveals that it hasn’t resulted in a single sale. While engagement is important, revenue keeps a business going. Ecommerce tracking can help you attribute a sales value to every visitor on your website.

How to Set Up Ecommerce Tracking in Matomo

There are two main stages to setting up Ecommerce tracking inside Matomo. In the first stage you’ll need to make sure you have enabled Ecommerce tracking within the Matomo interface. You can configure this when creating a new website in Matomo or you can add it later. Instructions for both scenarios are available below.

Stage One: Enabling Ecommerce Tracking in Matomo

How to set up a New Ecommerce Website in Matomo

The simplest way to set up ecommerce tracking is by enabling it when you are adding a new website to Matomo.
  1. Log into Matomo as a Super User.
  2. Click All Websites in the blue top menu to bring up the list of your existing sites (if any) and then click to Add a new website. This will bring up some options to define what you are measuring.
  3. Click on the Website button to confirm.
  4. Complete the necessary details about the website, such as the name and URL. You will find a short description of what each field should contain in a grey box next to it.
  5. Several fields down you will reach the Ecommerce settings. By default, new websites are set as Not an Ecommerce site so you will have to click on this dropdown to select Ecommerce enabled.
  6. In the following field, select the primary Currency that you operate in. This will impact both your Ecommerce and Goals reports.
  7. Finally hit the green Save button and your new ecommerce site will be enabled within Matomo. Congratulations, you can skip to Stage Two!

Enabling Ecommerce tracking for an existing website in Matomo

If you are already tracking a website inside Matomo without ecommerce enabled, you will need to update your website settings to turn on Ecommerce tracking.
  1. Click on the cog icon  in the Top Menu to load the Settings page.
  2. Visit the Measurables section from the Main Navigation on the left-hand side.
  3. Find the website you’d like to update and click the Edit icon. Note: you will need the “Write” permission to be able to edit the website.
  4. Scroll down the page until you reach the E commerce dropdown menu, and select Ecommerce enabled.
  5. Select the appropriate Currency option in the dropdown that follows.
  6. Scroll down and hit the green Save button to finish the first stage of setting up ecommerce tracking.
  7. To confirm that everything is working as expected click on the Dashboard link in the top menu. You should now see the Ecommerce menu item within the main navigation on the left hand side.

Stage Two: Enabling Ecommerce Tracking on Your Ecommerce Platform

The second stage consists of integrating Matomo Ecommerce tracking code with your website. Thanks to a large ecosystem of organisations using Matomo and developing integrations for third-party platforms, there are lots of ready-made plugins and extensions you can use to enable ecommerce tracking. You can find a full list of these, along with their setup instructions on the Matomo integrations page.             

Matomo for WordPress

In addition to the standard integrations there is also a dedicated version of Matomo for WordPress. The WordPress version of Matomo offers support for tracking the following ecommerce plugins out of the box:    Note: If you are using Matomo On-Premise with your WordPress site, you can track your WooCommerce orders with the Matomo WooCommerce Analytics plugin instead.

What if there isn’t an integration for my Ecommerce platform?

If you are using a custom ecommerce solution without a ready-made integration, then you will need to implement Matomo ecommerce tracking yourself. You can do this by adding the required JavaScript snippets to your cart’s custom code. These can be found in the advanced developer reference below. If you get stuck along the way, there is a helpful community of contributors on the Matomo forum. If you develop a new Matomo integration for your Ecommerce platform, it’d be wonderful if you would consider releasing it as open-source software! We would be happy to credit you and share it through our integrations page. It’s not uncommon for open-source projects to receive additional outside support, which can improve the end result for the whole analytics community.

What Data is Measured and Reported by Ecommerce Tracking?

A standard Ecommerce tracking setup within Matomo collects and reports on both individual and aggregate transaction data. Within the reports, you can benefit from the following metrics:
  • Ecommerce Orders – Keep track of the total number of website sales in aggregate, or over specific periods.
  • Products Purchased – You can track the number of products that have been purchased within your total orders. It is also possible to break this down further with the Products report to get detailed statistics.
  • Total Revenue – The amount of revenue generated from your sales (including tax, shipping, and subtracted discounts). See how much you’ve made within specific periods at a glance.
  • Subtotals – The order subtotal, excluding shipping and tax. This can help you get a better understanding of your sales revenue without having to account for varying regional and international charges.
  • Tax – The total amount of tax charged on all sales. Tracking or excluding this value can help you to understand your pre-tax and post-tax profits across your website.
  • Shipping – The total shipping costs charged on all sales. When plotted against revenue, you can work out the effectiveness of free shipping offers.
  • Discounts – The total discount applied to all sales. This helps to quantify the effective marketing costs of discount campaigns.
  • Average Order Value (AOV) – This is calculated from the total revenue divided by the total number of orders. It can be a useful metric to help you design and track the efficiency of campaigns to increase the value of your orders and ultimately increase revenue.
  • Ecommerce Orders Conversion Rate – This tells you what percentage of people that visit your website make a purchase. For an ecommerce focused website, this is likely to be one of your key performance indicators (KPI).
  • Abandoned Carts – The total number and potential revenue of visits where people added products to their shopping cart but ultimately left the site without making a purchase. Matomo also tracks this as a percentage. While this might not reach zero, you should always be aiming to decrease this number.

How to Analyse Ecommerce Reporting to Improve Your Sales

Ecommerce Overview

The Ecommerce Overview section is the best place to get a high-level view of your online store’s general performance. At a glance, you can see how many sales you’re making, how much revenue they are generating, and your website’s conversion rate. If you want to see how your sales have been trending over time, then you can review the evolution graph shown at the top of the Ecommerce Overview page. You can customise which data points are plotted on this graph by clicking on the grey metrics picker icon  at the top left. This brings up a list of metrics which you can click to enable. Currently enabled metrics will be shown with a green tick beside them. These are the metrics available by default:
  • Ecommerce Orders
  • Conversion Rate
  • Total Revenue
  • Purchased Products
  • Average Order Value
While looking at the relevant data in this view, you can hover over any of the data points to display the specific numbers for that period, as shown below. If you’d like to change the period each data point represents, move your mouse into the graph area and then click on the green calendar icon  that appears at the bottom left half of the card. Your selection here will update the chart to display data increments by the: DayWeekMonth or Year. Within the same green icon menu (shown above) you will also see a few other icons:
  • Export Icon  – This allows you to export the raw data to work with other tools.
  • Image Icon  – This generates an image of the chart so you can use it in external reports.
  • Annotation Icon  – This lets you review or add relevant annotations.

Ecommerce Annotations

If you have been using the  along the bottom of the evolution graph. You can either hover your mouse over these icons or click on them to reveal notes within your selected reporting period. This feature can be useful for keeping track of things, like when you launch new products, or make changes to the design of your ecommerce pages. Your notes here will often provide helpful context for sudden changes within your trends.

Ecommerce health check with sparkline summaries

The sparkline summary card just below the row evolution section provides a high-level overview of your Ecommerce statistics. The data shown in these charts and text summaries represent the date range you’ve selected via the Date Picker at the top of the page. The following statistics are displayed within the sparkline summary card:
  • Ecommerce Orders
  • Total Revenue
  • Average Order Value
  • Ecommerce Orders conversion rate
  • Purchased Products
  • Visits with Abandoned Cart
  • Revenue left in cart
  • Visits with Abandoned Cart
If you would like a closer look at any of these statistics over time, you can click on the summary to update the full-sized evolution graph above this section with the relevant data.

Understanding the Abandoned Cart Analytics

Cart abandonment happens when somebody adds a product to their shopping cart but for one reason or another, doesn’t make a purchase. Often the total value of products abandoned in online shopping carts, accounts for a large amount of lost potential revenue. Without analytics, you might never realise this was happening. Matomo can not only track how many people abandon their carts, but also the potential revenue that was lost in their carts. If you discover that you have a problem with lots of people abandoning carts you can use Matomo to dig into what might be happening. People may partially complete your checkout for many reasons. One common reason is unclear shipping details, i.e. where visitors only discover how much it will cost to get the product delivered after being forced through the checkout process. Knowing this, you might consider how you can expose this information earlier in the checkout flow. Sometimes people are simply checking your prices against competitors and plan to come back later. Or perhaps you force people to sign up to an account early in your checkout flow, which is putting them off? The first step is knowing you have a problem in this area.

Conversions Overview

The Conversions Overview card shows a simple text summary of the transaction values associated with your website orders. These statistics are displayed in the default currency you’ve configured for your website. Text summaries are provided of:
  • Total Revenue – Total value of sales after discounting, including tax & shipping.
  • Sub-totals – Total value of all sales, excluding shipping and tax.
  • Tax – The total amount of tax charged on all sales.
  • Shipping – The total charged for shipping on all sales.
  • Discounts – The total value of discounts applied to all sales.
All of these values are based on the Segment and Date Range selected at the top of the page. Below the data, there is a link to Show Visit Log segmented by this Goal. Clicking this link loads a popup containing full details for all of the visits that are contributing to these totals. The linked summary should offer the same detail as in the full Ecommerce Log, unless you have any filters enabled.

Ecommerce Log

If you’re just getting started with Ecommerce analytics and you haven’t made many sales yet, the Ecommerce log can be very helpful. It provides granular session-level data so you can look at the full session for each user that either made a purchase or abandoned their cart. This can help you identify which pages of interest users visited, or if they appear to have fallen out of your sales funnel at a particular stage. It can also be helpful when testing new flows to ensure sessions are acting as you expected in real-time.

Products

The Products view is useful for high-level statistics on product sales. It can help you identify over-performing and under-performing products. You can review sales and conversion rates in a table by either: NameSKU, or Category, to reveal trends and opportunities. All of the reports in this section can report on the following metrics:
  • Product Revenue
  • Quantity Sold
  • Unique Purchases
  • Average Price
  • Average Quantity
  • Conversion Rate
When hovering over a row in the table, you will see that a small line chart icon  appears. You can click on this to review an evolution graph for the highlighted row. You’ll also notice a percentage in light grey which shows the proportion of total sales this row represents.

Product Name and Product SKU Reports

As both of these reports are broken down on a per-product basis, they can help you understand which products your visitors are most interested in, and the impact they have on your business. It can also help you ensure you are driving traffic to the products which are most likely to convert. You may want to report by SKU (Stock-Keeping Unit) specifically if you sell a product in multiple sizes or quantities, that each share the same name, but have unique SKU numbers. This can allow you to differentiate between the variations of the product sold. Another example might be a site where you sell varying lengths of membership access – with each having the same product name, but holding unique SKUs. Another common reason to use SKU numbers is if the name of a product you sell changes, but the product is the same.

Product Category Report

The Product Category contains the same columns as the name and SKU report described above, but the metrics can be useful in a couple of different ways. Most commonly, it can be useful when your site sells different types of products. You may notice your sales pages convert well for low-cost consumer goods, but your high-end electronics don’t. This could lead you to run some experiments on how you present and sell products in your electronics category. If you are not running a traditional ecommerce store, you can also get creative with how you configure categories on your ecommerce platform. With the right ecommerce setup, you can set your categories to represent the different audiences your products appeal to. In this case, the category report will help you to understand how well you are reaching and converting your various audiences.

Reviewing Abandoned Carts by Product or Category

By default, all of the above reports are based on sales. However, it is also possible to analyse abandoned cart reports within this section too. To switch between modes, move your mouse over the table area and then click the green cart icon  that appears towards the bottom left. This will reveal the option to switch between Ecommerce Orders  or Abandoned Carts .

Sales

The next collection of reports relates to orders rather than the individual products within them. These sales reports can help you understand the conditions that lead to sales on your website. This covers things like: how purchasers discover your site, where the users come from, and how long it takes them to convert. Each report below will have the following columns: Visits, Ecommerce Orders, Total Revenue, Ecommerce order, conversion rate, Average Order Value, Purchased Products and Revenue per Visit.

Sales by Referrers

You might be surprised to discover that some traffic sources, deliver a lot of visitors, and even generate lots of engagement on your site, but they simply don’t convert into sales. For an ecommerce store, sales are your most important metric so it will pay to focus your marketing energy on the traffic sources that are leading to sales.
Channel Type Report
The channel report is useful for analysing how your revenue is growing. The amounts are broken down by type of traffic source, e.g. search or website referrals. As an example, imagine you are launching a new software product. To get some initial traction, you start promoting your product through referral websites that list new products. Your initial reports will show strong growth in traffic from websites and campaigns. But over time, as your site becomes more established, you would hopefully notice a shift towards more traffic and sales from search engines.
Search Engines Report
This report tracks not only which search engines are bringing you traffic, but also which ones are sending traffic that converts. Often people focus on the most popular search engines. However, if you notice a significant amount of traffic from specific search engines is resulting in lots of sales, it may be that they are delivering a different type of user. Strong sales on an alternative search engine could suggest it is worth exploring what advertising options they have to see if they can provide similarly outsized results. Or it could be that certain search engines present your site differently in their search results pages. If so, is there something you could learn from this and make use of for other elements of your online marketing?
Keywords Report
Within the Keywords report, you can see some of the specific search terms people use in Search Engines, such as Google, to find your website before making a purchase. While this report can’t identify every keyword used to reach your site for privacy reasons, it can help you to discover keywords that you might not have considered otherwise. If you are running paid search campaigns, you will likely want to set up campaigns targeting keywords that are showing sales here.
Websites Report
If you feature your website on third party websites, this report can help you to identify which of these sites bring in sales. In the case where you are actively paying to feature on those third party sites, this report can also help you to quantify your return on investment. Alternatively, you may see that some websites are bringing in lots of sales with little or no input. In this case, it may be worth exploring whether there are opportunities to strengthen your relationship with these sites.
Campaigns (Enabled via Matomo Campaigns Extension)
If you are using the cloud version of Matomo, or if you have the Marketing Campaigns plugin, you can also review sales by CampaignNameKeywordSourceMedium and Content. These dimensions are useful if you advertise through other channels such as email newsletters, paid ads, affiliates, etc. Learn more about Tracking Campaigns.

Sales Engagement

This section is useful for tracking the effectiveness of your site.
Visits to Conversion Report
This report shows how many visits it takes for your users to make an Ecommerce conversion on your site. One example of how to use the data in the Visits to Conversion report is, to build a case for regular email marketing and social media posts to regularly bring people back to your website.
Days to conversion Report
This report shows how many days it takes for your users to make a conversion after first visiting your site. You might notice in the Days to Conversion report that, for example, people tend to purchase seven days after they first visit your website. This fact could suggest you would benefit from sending an email campaign seven days after people first visit your site. Or you might see that people typically convert a month after visiting your site. This would suggest a need to develop a robust nurturing campaign to keep potential customers engaged with your brand over an extended period. Not all products will be sold on the first visit!

Sales by User location

The next section provides data based on how your website is accessed.
Country, Continent and Region Reports
These show where a user accessed your website from. A couple of examples of how you might use this type of data are:
  • If you have physical stores for your business, you might notice local visitors are more or less likely to purchase from your online store.
  • If there is significant interest from a particular part of the world, you might consider opening a new location or creating marketing campaigns more targeted to people in this area.
Devices: Type, Model & Brand Reports
While this may not be a primary metric for many sites, analysing sales by device might be an obvious choice for a software company. For example, if you sell an app that can only be used on iPhone or Android devices, then you will want to make sure you are reaching people on those platforms. However, there can be other reasons to investigate the devices people use to browse your site. For example, if you notice you get equal levels of traffic from Chrome and Safari browsers, but only one browser leads to sales. In that case, it might indicate a website compatibility error. You could follow up by running tests of your website in both browsers and discover that critical elements of your website display very differently, or even break in one of the browsers.

Sales by User attribute

Visits per server time
The Visits by server time report can help you identify user trends for marketing but also potential server related issues. For example, your website could run a backup schedule at 12 pm every day. This report could help you to notice a drop in sales at the same time every day. However, upon further investigation, you might realise this backup process is actually slowing down your site, which is the real reason for a drop in your conversion rates.
Custom Dimension Reports
This section will also contain a report for any Custom Dimensions that you have created. Reporting on your sales broken down by your custom dimensions is very powerful when you have configured relevant dimensions for your audience. Some example dimensions could be User Type (Admin, Author, Guest, etc) or login status for example. In the first case, you probably wouldn’t expect Admins to make a purchase so you can exclude them from consideration. And for the login status you could explore the relation between creating an account on your site and converting to a sale.

Extending Ecommerce Reporting with Multi Channel Attribution (Optional)

Multi Channel Attribution is a premium feature, which is included in Matomo Cloud by default, and can be purchased separately if you use the On-Premises or WordPress versions of Matomo. Often people visit your site more than once before they make a purchase. Multi Channel Conversion Attribution adds a reporting view that tracks the multiple different sources that have contributed to a sale, not just the most recent source. To provide an example, someone may have discovered you from search earlier in the year, then followed you on social media, and then bought a product after clicking over from your fan page. By default, Social Networks would get the credit, however, in a multi-attribution world that credit can be shared between the lead sources. You can review your sales reports with multiple different attribution models:
  • Last Interaction – This is the most commonly used attribution model on the web. It simply tracks how people reached you in the session where they made a purchase.
  • Last Non-direct – This is based on the same model above, but as a direct visit is often from a bookmark or non-advertising related source, it might be more useful to review the last meaningful source that you can use for optimising your future marketing.
  • First Interaction – This allows you to see how somebody first found your website, even if they subsequently made several visits to your site from different traffic sources.
  • Linear – In this model, the credit for a sale is split evenly between all interactions no matter at what stage of the conversion process they occurred.
  • Position Based – This allows you to allocate most of the credit (40% each) to both the first and last interaction as these are often the most important and then split the remaining 20% across all channels that assisted with the sale in between.
  • Time Decay – The final attribution model is based on how long an interaction occurred before a sale. It still assumes that the last interaction is the most relevant for pushing a visitor into a sale, however, it also allocates a decreasing amount of credit to the traffic source of each preceding visit to the website.
Exploring your ecommerce reports with alternative attribution models can provide you with a more nuanced view of your various traffic sources. For example, a specific search ad campaign might always bring in strong sales. However, more in-depth analysis reveals it is simply recapturing people who initially discovered you through an organic search. Multi-channel attribution can help you discover the real value of each site and how they are performing within your sales cycle. You can also use this knowledge to seek opportunities for improving the performance of specific channels at different stages of your sales funnel. Advanced: How to manually configure Ecommerce Tracking (For Developers) If your website isn’t powered by a content management system or ecommerce platform that integrates with Matomo, then it may need to be manually integrated. You can manually integrate Matomo with any cart software by adding snippets of JavaScript code to your checkout process. The code, described below, sends your user’s shopping cart data to Matomo to track key actions for your analytics. There are several categories of actions that you will need to integrate for a full Ecommerce tracking setup within Matomo:
  • Product Views (Optional) – This enables per-product conversion rates.
  • Cart Updates (Optional) – This enables tracking abandoned cart statistics.
  • Order Updates (Required) – This is a required component of Ecommerce tracking.

Advanced: Manually Tracking Ecommerce Actions in Matomo

Tracking Product Views in Matomo (Optional)

By default, Matomo can let you know your 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 Matomo will automatically calculate a product conversion rate for each product. Collecting product and category specific conversion rates can be helpful to identify where certain products may not have enough information, or where specific product categories are under-performing on your site. There is one JavaScript method for pushing both products and category view data to Matomo, and that is 'setEcommerceView'. The only difference between tracking products and categories is which parameters are attached to the call. For both, you will also need to make sure that you include a 'trackPageView' call. You can find more details and examples for both below.

Tracking Product Views in Matomo

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 either the category name passed as a string, or up to five unique categories as an array, e.g. ["Books", "New Releases", "Technology"]
  • price (Optional) – Integer/Float – The cost of the item.

Example Product View Snippet

// Push Product View Data to Matomo - Populate parameters dynamically
_paq.push(['setEcommerceView',
    "0123456789", // (Required) productSKU
    "Ecommerce Analytics Book", // (Optional) productName
    "Books", // (Optional) categoryName
    9.99 // (Optional) price
]);

// You must also call trackPageView when tracking a product view 
_paq.push(['trackPageView']);

Tracking Category Views in Matomo

The following parameters are required and recommended for tracking a category pageviews (not a product page):
  • productSKU – Boolean – This should be equal to false.
  • productName – Boolean – This should be equal to false.
  • categoryName (Required) – String/Array – This is either the category name passed as a string, or up to five unique categories as an array, e.g. ["Books", "New Releases", "Technology"]

Example Category View Snippet

// Push Category View Data to Matomo - Fill category dynamically
_paq.push(['setEcommerceView',
    false, // Product name is not applicable for a category view.
    false, // Product SKU is not applicable for a category view.
    "Books", // (Optional) Product category, or array of up to 5 categories
]);

// You must also call trackPageView when tracking a category view 
_paq.push(['trackPageView']);

Tracking Cart Updates in Matomo (Optional)

To track cart additions and removals, your cart system will need to send the details for every item that remains in the cart after a user adds or removes an item, including those already submitted from prior Add to Cart clicks. This is important to collect accurate information for the abandoned cart feature within Matomo. The data should be included within a “push”, which is the function that enables sending of structured data to Matomo via JavaScript. You will also need to supply the total value of all items in the cart. so the two required elements for cart tracking are:
  • A push of 'addEcommerceItem' for each product currently in the cart, including the name and SKU at a minimum.
  • A final 'trackEcommerceCartUpdate' push with the cart total passed as a parameter.

Example Product Cart Update

Each item processed as part of the cart update can contain the following parameters but must include the name and SKU at a minimum.
  • productSKU (Required) – String – A unique product identifier.
  • productName (Recommended) – String – The name of the product.
  • categoryName (Optional) – String/Array – This is either the category name passed as a string, or up to five unique categories as an array e.g. ["Books", "New Releases", "Technology"]
  • price (Optional) – Integer/Float – The cost of the item.
  • quantity (Optional) – Integer – How many of this item are in the cart. Defaults to 1.
The snippet below contains example data in the format required by Matomo. All of the parameters should be dynamically filled by your ecommerce platform.
// An addEcommerceItem push should be generated for each cart item, even the products not updated by the current "Add to cart" click.
_paq.push(['addEcommerceItem',
    "0123456789", // (Required) productSKU
    "Ecommerce Analytics Book", // (Optional) productName
    ["Books", "Best sellers"], // (Optional) productCategory
    9.99, // (Recommended) price
    1 // (Optional, defaults to 1) quantity
]);

// Pass the Cart's Total Value as a numeric parameter
_paq.push(['trackEcommerceCartUpdate', 15.5]); 

Tracking Orders to Matomo (Required)

Tracking orders is the minimum required configuration for a successful ecommerce tracking implementation. Order metrics are likely to be the most valuable for any ecommerce store, so you need to make sure that you set up order tracking correctly. There are two main elements required to push an ecommerce purchase to Matomo:
  • Product details for each product purchased, containing the Product SKU at a minimum.
  • Order details; containing a unique order ID and the total revenue at a minimum.
The order is typically tracked on the order confirmation page after payment has been confirmed. Note: The unique order ID generated by your cart software ensures the same order isn’t tracked twice. One additional consideration if you enable “Anonymize Order ID” in Matomo’s privacy settings, duplicate orders may still be counted for page reloads.

Example of Adding a Product to the order

The snippet below contains example data in the format required by Matomo. All of the parameters, which are shown within double quotation marks, should be dynamically filled 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 either the category name passed as a string, or up to five unique categories as an array, e.g. ["Books", "New Releases", "Technology"]
  • price (Optional) – Integer/Float – The cost of the item.
  • quantity (Optional) – Integer – How many of this item are in the order. Defaults to 1.
The Code Example:
// Product Array
_paq.push(['addEcommerceItem',
  "01234567890", // (required) SKU: Product unique identifier
  "Ecommerce Analytics Book", // (optional) Product name
  "Books", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
  9.99, // (Recommended) Product Price
  1 // (Optional - Defaults to 1)
]);

Example of Tracking the Ecommerce Order

The second part of the order update code passed to Matomo is a summary of the order. At a minimum, it should include an order ID and the total revenue value. The variables passed, in order, are:
  • orderId (Required) – String – A unique reference number to avoid duplication.
  • revenue (Required) – Integer/Float – The order total including tax & 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) – Integer/Float – The amount charged for shipping.
  • discount (Optional) – Integer/Float/Boolean – Discount offered? Default to false. Otherwise, you should include a numeric value.
The Code Example:
// Order Array - Parameters should be generated dynamically
_paq.push(['trackEcommerceOrder',
    "000123", // (Required) orderId
    10.99, // (Required) revenue
    9.99, // (Optional) subTotal
    1.5, // (optional) tax
    1, // (optional) shipping
    false // (optional) discount
]);

Developer Warning: Currency Variables must be passed as an Integer or Float

The following currency parameters must be supplied as integers or floats, not as strings:
  • addEcommerceItem() Parameters:
    • Price
  • trackEcommerceOrder() Parameters:
    • grandTotal
    • subTotal
    • tax
    • shipping
    • discount
For example, all the following values are not valid currency variables:
  • “5.3$”
  • “EUR5.3”
  • “5,4”
  • “5.4”
  • “5.44”
The following values are valid currency variables:
  • 5
  • 5.3
  • 5.44
If your Ecommerce software provides the values as string only, 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 currency symbols or other characters, for example “554.30”. You can then pass that value through the function as shown:
parseFloat("554.30");
Note: The JavaScript function parseFloat() does not support comma separated decimal values “25,3” so you might also have to replace the commas with dots first.

Other JavaScript functions that you may find useful

The following options may be useful especially when your Ecommerce shop is a Single Page App:
  1. removeEcommerceItem(productSKU) – This removes a product from the order by SKU. You still need to call trackEcommerceCartUpdate to record the updated cart in Matomo.
  2. clearEcommerceCart() – This clears the order completely. You still need to call trackEcommerceCartUpdate to record the updated cart in Matomo.
  3. getEcommerceItems() – Returns all ecommerce items currently in the untracked ecommerce order. The returned array will be a copy, so changing it won’t affect the ecommerce order. To affect what gets tracked, use the methods: addEcommerceItem()removeEcommerceItem()clearEcommerceCart(). Useful to see the list of what will be tracked before you track an order or cart update.

Ecommerce API Notes

Several additional functions you may find useful are documented in the Matomo Ecommerce Developer documentation for the JavaScript Tracking API. Once you have your Ecommerce data logged in Matomo, you can also access all of the reporting data via the Matomo API. Learn more about the Ecommerce Analytics Reporting API.

Further resources

Measuring the Ecommerce funnel steps

If you would like to track your full sales funnel, check out the Funnel Tracking feature. It allows you to track your visitors progress through your sales funnel even if it includes pages which aren’t specifically Ecommerce focused.

Measuring 100% of Ecommerce interactions using server-side tracking

When using the JavaScript tracker code, a small percentage of the ecommerce requests will not be tracked for various reasons (such as adblockers). If you would like your Matomo reports to 100% reflect your Ecommerce sales, follow the steps in Measure 100% of Ecommerce interactions using server-side tracking