I’m checking Matomo to see if it could cover our needs. From the tracking part it looks amazing, what I’m wondering is if I can send events with properties from the server-side.
Use case:
We want to know how many tickets a segment generated.
So, from the server I would send an event to Matomo telling: UserId → 100 tickets.
Then I would filter by camp
Yes, you can send events with properties from the server-side to Matomo using the Tracking HTTP API.
To achieve your use case, you can use the Matomo Tracking API to send an event with custom properties. Here is an example of how you can achieve this using the Matomo PHP Tracking Client library:
phpCopy code
use Piwik\Tracker\Client;
use Piwik\Tracker\Request;
use Piwik\Tracker\Tracker;
// Set up the Matomo Tracker object
$tracker = new Tracker($idSite, $apiUrl);
$tracker->setTokenAuth($authToken);
// Set up the request object
$request = new Request($query, $userAgent, $ip);
// Create a new tracking client
$client = new Client($tracker, $request);
// Send a custom event with properties
$client->doTrackEvent('Tickets', 'Segment Generated', '100 tickets', array('userId' => 100));
In this example, the doTrackEvent method is used to send a custom event named “Segment Generated” with the category “Tickets” and an action of “100 tickets.” The array('userId' => 100) parameter is used to set a custom property for the event, in this case, the user ID.
Once you have sent the events with custom properties, you can filter and segment them in Matomo based on the properties that you have defined, such as the user ID in your example.
Just to be clear, is possible to send the action as an integer 100, so later, I can filter and get 100?
So make it more clear:
userA came from facebook, campaignId 1. Later from the server I sent the tickets event with value 100
userB came from facebook, campaignId 2. Later from the server I sent the tickets event with value 200
userC came from facebook, campaignId 2. Later from the server I sent the tickets event with value 300
Then If I filter for facebook, I will see (between all the other metrics), that tickets=600
If I filter for facebook/campaignId2, then the total number of tickets will be 500
and facebook/campaignId1, has a total of 100 tickets.