0
votes

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:

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'}]);

1

1 Answers

2
votes

The solution you mention should work, but a delay may appear (about one hour, for instance):

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
  }
]);