Post object, not string, when using trackEvent; add event properties beyond “Category”, “Action”, “Name” and “Value”

I’ve added some tracking code like this in my website:

_paq.push(['trackEvent', 'Car construction', 'Add wheel', wheelId]);

However, I was wondering if it was possible to add more info to this event. Something like this:

_paq.push(['trackEvent', 'Car construction', 'Add wheel', {carName: "Buick", wheelCount: 3, wheelId: wheelId}]);

It’s a made-up example, but the thing is, I want to connect more than one value/property to my event. I’ve seen this in mixpanel, but it isn’t clear from the Piwik docs how/if this is possible. So I’m guessing not, but wanted to be sure.

The last answer in this question says I “may use trackEvent with any number of custom variables.” But I’m confused, as I thought you can only pass in Category, Action, Name and Value in the trackEvent function?

Joining the question.
We have a wizard to create an event on our Events Company website. An event has many different properties, like duration in hours (numeric), category (“sales”, “anniversary” etc), premium status (“premium”, “regular”), guest number category (“<50”, “50-100”, “100+”) and others.

I would like to attach this information to every event created, and to build multiple dashboards showing the ratio of, say, “sales” VS “anniversary” events, or “premium” VS “regular” events.

I cannot use custom dimensions for these properties for 2 reasons:

  1. there might be more than 15 attributes in one event
  2. we have several entities to track on the website, and each entity has it own set of attributes.

Question: can I add event-specific attributes to a Matomo Event given that documentation mentions only 4 static properties “Category”, “Action”, “Name” and “Value”?

Hi @Iryna_Tyshko

You can define up to 50 action custom dimension:

I think you’ll have to share some dimensions from one action category to another one…
If you use custom reportspremium plugin, you can filter the report, per action category for example…

Thank you @heurteph-ei ,
Unfortunately sharing is not an option because I have over 50 events so far, each having at least 5 custom properties. What we really need is to specify the properties specific to a certain event, like they do it in Mixpanel, for instance.

Hi @Iryna_Tyshko
The only alternative solution I see is the use of deprecated custom variables:

The remedy would be to track multiple events, each capturing some of the data that you’re hoping to collect for example under the same category.

Using an example of a browser based game, this could be configured for example:

Event Category: Level Completed
Event Action: Level 38

Then track another Event for each parameter:
Event Category: Level Completed
Event Action: Difficulty
Event Name: Very Hard

And so on for each of the parameters you wish to collect. You can change this around or customise it to track the data into either different categories or the same categories as shown with each “Action” tracked as its own event.

An alternate solution to using event tracking for this information would be to use Custom Dimensions: https://matomo.org/docs/custom-dimensions/
You can setup the Custom Dimensions as “Action” scope and track each custom dimension with the data you wish, for example:

  • Level Completed: 38
  • Difficulty: Very hard
  • Score achieved: 455
  • Easter eggs found: 2
  • Lives lost: 1
  • Lives remaining: 2
  • Enemies disabled: 43

The main downside of using Custom Dimensions to track this data is that you would need to create and name the custom dimensions before tracking data to them. However, it can be much more flexible for adding these dimensions to segments or Custom Reports.

As you mentioned though that you have potentially many different possible properties, but if this is up to a known limit then you could create the Custom Dimensions with generic names such as “Notification Dimension 1” and so on. (answer by Richard, posted here by Genest)

1 Like