E-commerce in Matomo

E-commerce is always felt as a trauma for analysts as understanding the documentation which go along with the implementation of this feature redirect them toward asking help for developers.

It does not have to be this way, in fact it really depends of how your website is built, is all the information about the e-commerce order confirmation, you can always use a dirty method named scraping in order to use the e-commerce analytics tracking without adding any code to the source code of your page. But most of the time you wouldn't want to go this way and will prefer to use a clean method... which require some coding skills.

Ok but why do you need coding skills to implement the e-commerce analytics tracking code? The reason behind is that most of the time the data about an e-commerce order are a bit confidential so will be hosted within a database rather than displayed on the page. As a result you need a server side programming language, mainly PHP, in order to fetch those data, pull them and insert them within the tracking code. That's the reason why all documentations will ask you to press the button "call a developer" in order to implement it. The truth is that in any cases developers will go through the documentation as well in order to implement this tracking code so if you have a couple of days in front of you, good chances that you can achieve the same result as what developers can do in a couple of hours.

By the way, do not think that it is 100% easy for developers too. They know programming languages but they probably don't have a clue about the analytics solution you are showing them. So this is your role to explain what it does and why do you need it.

Ecommerce tracking 101 with Matomo Analytics

Probably, the best way to approach ecommerce is to install a WordPress with the WooCommerce plugin + adding their datafeed example + authorizing payment by check (it will avoid you to play with your credit card and make multiple transactions without stress).

Ok, next, enable the ecommerce function within Matomo in order to see that the ecommerce category will appear... Whaoo champion.

Ok, next, install the following plugin for WordPress "Edit WooCommerce Templates" it will allow you to edit directly the pages you would like to insert tracking into.

The Thank you page

The first page we are going to have to have an interest in is the thank you page, as this is the page recording the transaction.

We need to have the following data for each item:

  • productSKU
  • productName
  • productCategory
  • price
  • quantity

and for each order:

  • orderId
  • revenue
  • subTotal
  • tax
  • shipping
  • discount

So we need to find a way to extract those data out, it really depends of the technology you are using, in our case, this is WooCommerce which is using PHP functions, so one can extract data this way:

orderId is <?php echo $order->get_order_number(); ?>

revenue is <?php echo $order->get_total(); ?>

Last modified: Wednesday, 15 April 2020, 3:44 PM