CustomVars - Segmentation Problem

Hello everyone,

I have a problem with the CustomVars. I would like to use Piwik to provide the users of my site a statistic. Each user has a profile on the website with pictures / videos, etc…

I would like to track the profile call and every single media data call, among other data Piwik offers anyway. In addition, there are different types of profiles, depending on which device the profile was opened (Smartphone, Tablet, PC browser).

I use the CustomVars for tracking, which works pretty well so far:

$ T-> setCustomVariable (1, ‘action’, $ _REQUEST [‘action’], ‘page’); / / profile or media
$ T-> setCustomVariable (2, ‘ProfileID’, $ _REQUEST [‘ProfileID’], ‘page’);
$ T-> setCustomVariable (3, ‘Mediaid’, $ _REQUEST [‘MediaID’], ‘page’) / / might be null on action = profile
$ T-> setCustomVariable (4, ‘type’, $ _REQUEST [‘type’], ‘page’) / / different profile types

$ T-> setCustomVariable (1, ‘v-action’, $ _REQUEST [‘action’], ‘visit’);
$ T-> setCustomVariable (2, ‘v-ProfileID’, $ _REQUEST [‘ProfileID’], ‘visit’);
$ T-> setCustomVariable (3, ‘v-Mediaid’, $ _REQUEST [‘MediaID’], ‘visit’);
$ T-> setCustomVariable (4, ‘v-Type’, $ _REQUEST [‘type’], ‘visit’);

But I have problems with the evaluation (I use the PHP Api).

Clicking on a profile I can track with:
array (‘module’ => ‘API’, ‘idSite’ => 1, ‘method’ => ‘Actions.getPageUrls’, ‘date’ => ‘today’, ‘period’ => ‘month’, ‘format’ => ‘PHP’, ‘expanded’ => 1, ‘segment’ => ‘== customVariableValue1 profile; customVariableValue2 == 34’)
the unique visitors (or hits) quite well.

The result also agrees, unless I click a media file, which then makes another entry in the “piwik_log_link_visit_action”.
The two entries in the “piwik_log_link_visit_action” look properly:

Once upon opening of the profile:
custom_var_v1 = profile
custom_var_v2 = 34
custom_var_v3 =
= custom_var_v4 smartphone

Secondly, when playing a media file:
custom_var_v1 = media
custom_var_v2 = 34
custom_var_v3 = 85
= custom_var_v4 smartphone

But unfortunately this visit is after clicking a media file no longer counted in the unique visitors query above. In the data table “piwik_log_visit” changed the entry under custom_var_v1 from “profile” to “media”. I thought, however, that the queries with Actions.getPageUrls always refer to the “piwik_log_link_visit_action”?

Apart from the fact that this method is quite performance consuming, it would be ok for me, if I would get correct results. It would be better, of course, to directly relate the query to CustomVars (CustomVariables.getCustomVariablesValuesFromNameId idSubtable + = XX), but I have not even made it there to use another CustomVar in the segmentation part (eg Action + ProfileID).

What am I doing wrong? Which way would you go then? How can I make my own actions and count them, but simultaneously maintain to the mechanism of unique visitors?

Hope I have expressed myself somewhat understandable that someone knows the problem and can help me out.

Chris

You are experiencing the bug: Add support for segmentation on "page" scope Custom Variables · Issue #2633 · matomo-org/matomo · GitHub - see the ticket for more info

Feature is tracked in Segmentation: Support "IS NULL" and "IS NOT NULL" type queries · Issue #3932 · matomo-org/matomo · GitHub