@tedo-develop opened this Issue on November 6th 2019

Hello,

i tried to get contentPieces from matomo via api call.
I'am really sure that the call below worked for nearly 2 years (the call was never changed).

index.php?module=API&method=Contents.getContentPieces&idSite=1&period=day&date=2019-10-30&filter_limit=100&format=json&segment=contentName%3D%3DNameOfContent%3BcontentPiece%3D%3DNameOfContentPiece

I get a response, if i call the api with &segment=contentName==NameOfContent
But i get no response if i call the &segment=contentPiece==NameOfContentPiece

Also no response if i call a combination e.g.

index.php?module=API&method=Contents.getContentPieces&idSite=1&period=day&date=2019-10-30&filter_limit=100&format=json&segment=contentName%3D%3DSuper%20Top%20Banner%3BcontentPiece%3D%3Da-877-10177040-IGE%252BXAO%2BSoftweare%2BVertriebs%2BGmbH

What did i wrong? Is there any bug known?

@sgiehl commented on November 6th 2019 Member

Checked a similar call on my local installation and it returns the expected data.
Did you try querying some data for a more wider time range to ensure there actually is some data that would be returned?

@tsteur commented on November 6th 2019 Member

@tedo-develop can you ideally also let us know the exact segment string in the query that you are using? We did change a few things around encoding so maybe there's an issue. To reproduce we will need to know the exact segment string.

@tedo-develop commented on November 7th 2019

@sgiehl i tried day, week, month result: [] (empty response). My first suspicion was, that there are no data in these ranges. But a look in our databases shows me that the last data were received on 2019-10-31. I'm not sure when we have exactly updated but i think it was on last week.

@tsteur thats are the segments we call. Hope you have all infos you need:
segment=contentName==Super Top Banner
; (AND)
contentPiece==a-877-10177040-IGE+XAO+Softweare+Vertriebs+GmbH

Complete request (rawurldecoded):
index.php?module=API&method=Contents.getContentPieces&idSite=1&period=day&date=2019-10-30&filter_limit=100&format=json&segment=contentName==Super Top Banner;contentPiece==a-877-10177040-IGE+XAO+Softweare+Vertriebs+GmbH

Last successful call (2019-10-31):
index.php?module=API&method=Contents.getContentPieces&idSite=1&period=day&date=2019-10-31&filter_limit=100&format=json&segment=contentName%3D%3DBillboard%20Banner%3BcontentPiece%3D%3Da-858-0-U.I.%20Lapp%20GmbH%20-%20August

Response after update:
[{ "label": "a-854-0-SSB Award", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-854-0-SSB+Award", "idsubdatatable": 2 }, { "label": "a-858-0-U.I. Lapp GmbH - August", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-858-0-U.I.+Lapp+GmbH+-+August", "idsubdatatable": 1 }, { "label": "a-886-0-Dassault Systemes Deutschland GmbH - Oktober", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-886-0-Dassault+Systemes+Deutschland+GmbH+-+Oktober", "idsubdatatable": 3 }]

As you see, i get data but not the expected. The second array is that response what i would expected. In my opinion, i should get only the second array as response, correct?

I have also spoken with our developers, nobody have change something. Maybe the call was the whole time incorrect?

@franzdumfart commented on November 7th 2019

We have a similar issue. When using segments we get confusing/wrong results. We use the API method Contents.getContentNames and filter the results via segments like this "contentPiece==company_123".

This is no longer working. The segment filter is ignored. We also did not change anything on the code side.

@tsteur commented on November 7th 2019 Member
@tedo-develop commented on November 12th 2019

@franzdumfart some ideas why the call not working for you? Which matomo version have you? We working with v.3.12.0. As far as we known, just the contentPiece segment is affected.

We tried simple calls like contentPiece==comapany, also wrong results.

@tsteur commented on November 12th 2019 Member

@tedo-develop how exactly would you describe "wrong results"? Be good to explain further so we can understand better

@tedo-develop commented on November 12th 2019

Same call as i subscribed in https://github.com/matomo-org/matomo/issues/15121#issuecomment-551033576. But this time we have tried a simple string just contentPiece==comapany (without spaces or special chars). Every time we get an empty response or more results than expected.

As you can see in https://github.com/matomo-org/matomo/issues/15121#issuecomment-551033576 the search string was contentPiece%3D%3Da-858-0-U.I.%20Lapp%20GmbH%20-%20August

The expected result was:
[{ "label": "a-858-0-U.I. Lapp GmbH - August", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-858-0-U.I.+Lapp+GmbH+-+August", "idsubdatatable": 1 }]

But we get:
[{ "label": "a-854-0-SSB Award", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-854-0-SSB+Award", "idsubdatatable": 2 }, { "label": "a-858-0-U.I. Lapp GmbH - August", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-858-0-U.I.+Lapp+GmbH+-+August", "idsubdatatable": 1 }, { "label": "a-886-0-Dassault Systemes Deutschland GmbH - Oktober", "nb_uniq_visitors": 53, "nb_visits": 56, "nb_impressions": 57, "nb_interactions": 0, "interaction_rate": "0%", "segment": "contentPiece==a-886-0-Dassault+Systemes+Deutschland+GmbH+-+Oktober", "idsubdatatable": 3 }]

@diosmosis commented on November 12th 2019 Member

@tsteur I thought it might be the segment encoding, but that doesn't appear to be the case since decoding the segment twice doesn't change any of the values used in the segment.

To be sure we could try the segment w/ twice encoded values to see if that provides a different result, ie,

contentName%3D%3DBillboard%252520Banner%3BcontentPiece%3D%3Da-858-0-U.I.%252520Lapp%252520GmbH%252520-%252520August

or

contentName%3D%3DBillboard%2520Banner%3BcontentPiece%3D%3Da-858-0-U.I.%2520Lapp%2520GmbH%2520-%2520August

@tsteur commented on November 12th 2019 Member

The description of @tedo-develop sounds expected behaviour which is due to https://github.com/matomo-org/matomo/issues/11900 where we fixed an issue and it's expected that more results (other labels) are not shown. It used to be a bug that no other labels are shown.

Not sure if there's still an issue though when there is no data. @tedo-develop could you try the suggested segment string in the URL for example?

@tedo-develop commented on November 12th 2019

I tried the the suggested segment string with postman. As you can see i get all contentPieces from 2019-10-30 and not only the requested/expected contentPiece.

Screenshot 2019-11-12 at 12 10 15

Search on matomo frontend gives this result:
Screenshot 2019-11-12 at 12 09 11

As far as i know the frontend works with filters so i tried a request with filters:
index.php?module=API&method=Contents.getContentPieces&idSite=1&period=day&date=2019-10-30&filter_limit=100&format=json&filter_column%3Dlabel&filter_pattern=lapp

Response:
Screenshot 2019-11-12 at 12 47 48

So i get my expected response, except the contentTarget (should have one, but not sure this is a matomo problem)

Is this the expected behavior in future? Should we use the filter parameter for specific contentPiece requests?

@franzdumfart commented on November 12th 2019

@tedo-develop Using the same version as you. On my end the segment filter will be ignored. No difference when using it.

@tsteur commented on November 12th 2019 Member

I tried the the suggested segment string with postman. As you can see i get all contentPieces from 2019-10-30 and not only the requested/expected contentPiece.

This is expected behaviour since Matomo 3.12 see #11900 . It was a bug that it was showing only the matching one. Filters help indeed in this case 👍

The contentTarget we actually removed in 3.12.0 as it was buggy and potentially showing wrong information (eg if there's one content piece with two different content targets).

@franzdumfart commented on November 13th 2019

Okay I've found a way to fix this problem when fetching Contents.getContentNames. Because my segment filters are ignored I've made the result flat, filter by label and then use the filter pattern. This works.

But getting event data (Events.getCategory) seems to work with segments. At least I think so. We track a category (video), an action (play) and a name (company_123). When checking this via the Matomo site via this URL I'm getting one result.

/index.php?date=2019-11-08&viewDataTable=table&module=Events&action=getAction&secondaryDimension=eventName&idSite=2&period=day&random=485&filter_offset=0&flat=1&totals=1&filter_limit=10&filter_sort_column=nb_events&filter_sort_order=desc&enable_filter_excludelowpop=0&keep_totals_row=0&include_aggregate_rows=0&show_dimensions=0&filter_column=label&filter_pattern=company_3144

Screenshot 2019-11-13 at 09 09 43

When trying to get the same data via different settings (we use this repo for fetching matomo data: https://github.com/RobBrazier/Laravel_Piwik)

  • method: Events.getCategory
  • flat = true
  • secondaryDimension = eventAction
  • segment = eventName==company_3144

I'm getting two results. But my guess is that the data is correct. When changing the segment the results are also changing, so the segment does some filtering. So there seems to be wrong results somewhere.

Any idea?

@tedo-develop commented on November 13th 2019

@franzdumfart as i described in https://github.com/matomo-org/matomo/issues/15121#issuecomment-552862703. It seems that filter_pattern is the only way to get "the correct result".

@tsteur if i understood everything right. I can't request anymore contentName==Banner&contentPiece==Company1 ?

But the doc says that we can combine segments for filtering?

Screenshot 2019-11-13 at 12 24 03

@franzdumfart commented on November 13th 2019

@tedo-develop Yeah but how can I get event data by name, category and action? Because in my example I can not search by filter_pattern because at this point the label does not include the name I'm searching for.

For me this seems like a bug.

@tedo-develop commented on November 13th 2019

@franzdumfart for me too. My suggest was only an idea how you can get your needed results.

Would be nice if the segments working again. If not, please let us know, so we can change our requests to avoid unnecessary requests. Luckily our code can handle the overhead....

@tsteur commented on November 13th 2019 Member

contentName==Banner&contentPiece==Company1

you can still combine multiple segments to narrow down your visitors.

For me this seems like a bug.

Would be nice if the segments working again. If not, please let us know, so we can change our requests to avoid unnecessary requests. Luckily our code can handle the overhead....

This is really how segments are supposed to work. Most users would argue it was buggy before so it's bit tricky and we can understand the frustration. There is no way to make everyone happy. You can disable this behaviour for a while but we might remove this flag in Matomo 4: You can disable it by adding this in config/config.ini.php:

[General]
enable_segments_cache = 0 

Another alternative be to use Custom Reports which supports Segment Filters (which are different from segments).

Powered by GitHub Issue Mirror