I'm trying to adapt a solution from Google Analytics to Matomo. In Google Analytics I have:
- 3 custom dimensions (dimension1, dimension2, dimension3 used to store information about user account / preferences saved)
- 1 custom event that fired when a download happens
My code is something like:
function track_download(data) {
var GA = window.ga || function() {
// ga is not defined, log function arguments
if (window.console) {
console.log([].slice.call(arguments));
}
};
// Custom dimensions
GA('set', 'dimension1', data.some_profile_information1);
GA('set', 'dimension2', data.some_profile_information2);
GA('set', 'dimension3', data.some_profile_information3);
// Track event
GA('send', {
'hitType': 'event', // Required.
'eventCategory': 'page', // Required.
'eventAction': 'custom_download', // Required.
'eventLabel': data.the_title_of_downloaded_section,
'eventValue': 1
});
};
Then in Google Analytics I can have custom reports like:
- the most used profile types by active members
- the most active download sections
- the number of downloads (total / also per section)
Is it possible in Matomo to send custom dimensions with a custom event in order to have the same reports / behavior?
UPDATE:
- solved definition of custom dimensions by installing the Custom Dimensions plugin and adding a new Action Dimension corresponding to each one used in GA.
- TODO custom event to track downloads + details on these dimensions. Found something: https://developer.matomo.org/guides/tracking-javascript-guide#custom-dimensions
UPDATE:
Tried like this, no data in reports of custom dimensions.
var MA = window._paq || function() {
// Matomo is not defined, log function arguments
if (window.console) {
console.log([].slice.call(arguments));
}
};
MA.push([
'trackEvent',
'page', // category
'my_custom_download', // action
data.item_title, // name
1, // value
{ // custom dimensions
dimension1: data.dim1,
dimension2: data.dim2,
dimension3: data.dim3
}
]);
And this is from docs:
_paq.push(['trackEvent', category, action, name, value, {dimension1: 'DimensionValue'}]);