HTTP API and Ecommerce tracking

Hello, we’re attempting to implement ecommerce tracking through the API and the documentation is either incorrect or not very helpful.

From what I can understand from the docs, ecommerce tracking involves two steps: 1) adding an item to a cart, 2) completing the transaction.

But the API documentation isn’t clear about that. So we implemented two functions in our software: Started and Completed.

Our Started request to the API is as follows:

{"idsite":1,"rec":1,"idgoal":0,"url":"http://localhost:3000/account/my-profile","ua":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0","uid":"","ec_items":"%5B%5B%22thirty_day%22%2C%2230%20Day%20Membership%22%2C%22Membership%22%2C29.99%2C1%5D%5D","ec_st":29.99,"ec_tx":false,"ec_sh":false,"ec_dt":false,"revenue":29.99,"send_image":0,"apiv":1}

Where our completed is:

{"idsite":1,"rec":1,"idgoal":0,"url":"http://localhost:3000/account/my-profile","ua":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0","uid":"","ec_items":"%5B%5B%22thirty_day%22%2C%2230%20Day%20Membership%22%2C%22Membership%22%2C29.99%2C1%5D%5D","ec_id":"d53e068b-2e21-4fa6-b47d-a8d1d66f65fc","ec_st":29.99,"ec_tx":false,"ec_sh":false,"ec_dt":false,"revenue":29.99,"send_image":0,"apiv":1}

This is after a lot of troubleshooting and adding fields that the documentation says are optional, but do not appear to be. The deciding factor that seems to distinguish “adding” to “completing” is including the “revenue” field.

This works mostly, but it’s not recording any detail of the transactions (sku, item name, etc). Only the total amount of each transaction. We’re at a loss as to how to proceed so that we record each transaction including its items.

The documentation we’ve looked at is conflicting as to which fields to include in each request:

Any clarification/help is appreciated.

=== UPDATE 7 June 2024 ===

For those that may have trouble with the ecommerce API in the future:

I appears that the order of operations for the API and ecommerce is as follows:

  1. Create/update the cart – Each time you do this, the ecommerce log in matomo will show an abandoned cart immediately. This is misleading, but now I understand what’s happeneding.

  2. Complete the purchase – Send the same data as the cart creation/update, but include the ec_id, which is the indication to matomo of a completed purchase. This will convert the abandoned cart in #1 to a transaction.

The fields we include for each are as follows:

  1. Create/update cart – idsite, rec, idgoal, uid (email address), ec_items, revenue, send_image

  2. Complete purchase – idsite, rec, idgoal, uid (email address), ec_items, revenue, send_image, ec_id

As you can see, the only difference is the addition of the ec_id in the final purchase API call.

I’d like to suggest updating the API and other documentation to make this more clear. We had to do a lot of troubleshooting and testing including various parameters in the API call to finally understand how this works.

1 Like

Hi @tarkin79
For documentation update, you can create a ticket in GitHub to be taken into account: