API: No results when using segements with years


We have some weird effects in our matomo reports when we use segments. I can reproduce the underlying problem using the API, where I’m getting inconsistent results using different periods.

I get expected results when i use period=month


<?xml version="1.0" encoding="utf-8" ?>

But following request using period=year gets an empty result:


<?xml version="1.0" encoding="utf-8" ?>
<result />

How is that possible? Any hints how I can dig into this?

Thanks for your help.

I would appreciate any hint.

Did you run into a timeout when the segment was created?

Segments create statistics from the raw data tables - are these tables present for the selected period? Did you try to pre-process this segment?

Hi Peterbo, thanks for your help.

I can’t tell if the preprocessing timed out, but this would make sense and could cause the inconsistencies.

The raw data tables aren’t available for 2017 anymore. Is there a chance to keep the already archived monthly report data and to recreate the year reports based on the monthly reports rather than the raw log data?

No, not for segmentation, unfortunately. Segmentation is always calculated from the raw data. Only if you are pre processing your segment (while the raw data is still present), it will be loaded from the archive tables (and will still be available even if the raw data is deleted). Raw data can’t be recreated from the archive tables. Only from e.g. logfiles via --replay-tracking parameter.

Are you using cron to schedule the report processing? If so, have you checked to ensure that “year” is set to be processsed also?

I know that visitors and users by default do not process for the year by default, although your api example was for page urls and so this should not be the issue.

Also, check out the following to aide debugging this query: