Reporting API: Bulk Request with different segments responds with same data

Hello,

It looks like only one segment is getting considered when using the Piwik Reporting API and doing a Bulk Request.

The request looks like this:
https://server.com/piwik/index.php?token_auth=TOKEN&module=API&format=json&method=API.getBulkRequest
&urls[0]=method=Goals.get&period=day&date=2015-04-02,2015-04-03&idGoal=ecommerceOrder&segment=searches>=1&idSite=2
&urls[1]=method=Goals.get&period=day&date=2015-04-02,2015-04-03&idGoal=ecommerceOrder&segment=searches==0&idSite=2

(Parameters after urls[0] and urls[1] are url-encoded, as written in the Piwik API documentation)

Response:


array
  0 => 
    object(stdClass)[1428]
      public '2015-04-02' => 
        object(stdClass)[1088]
          public 'nb_conversions' => int 16
          public 'nb_visits_converted' => int 15
          public 'revenue' => float 3322.06
          public 'revenue_subtotal' => float 3230.71
          public 'revenue_tax' => float 552.88
          public 'revenue_shipping' => float 91.35
          public 'revenue_discount' => int 0
          public 'items' => int 140
          public 'avg_order_revenue' => float 207.63
          public 'conversion_rate' => string '1.04%' (length=5)
      public '2015-04-03' => 
        object(stdClass)[1089]
          public 'nb_conversions' => int 3
          public 'nb_visits_converted' => int 3
          public 'revenue' => float 661.98
          public 'revenue_subtotal' => float 652.03
          public 'revenue_tax' => float 107.98
          public 'revenue_shipping' => float 9.95
          public 'revenue_discount' => int 0
          public 'items' => int 11
          public 'avg_order_revenue' => float 220.66
          public 'conversion_rate' => string '0.82%' (length=5)
  1 => 
    object(stdClass)[1084]
      public '2015-04-02' => 
        object(stdClass)[1085]
          public 'nb_conversions' => int 16
          public 'nb_visits_converted' => int 15
          public 'revenue' => float 3322.06
          public 'revenue_subtotal' => float 3230.71
          public 'revenue_tax' => float 552.88
          public 'revenue_shipping' => float 91.35
          public 'revenue_discount' => int 0
          public 'items' => int 140
          public 'avg_order_revenue' => float 207.63
          public 'conversion_rate' => string '1.04%' (length=5)
      public '2015-04-03' => 
        object(stdClass)[1086]
          public 'nb_conversions' => int 3
          public 'nb_visits_converted' => int 3
          public 'revenue' => float 661.98
          public 'revenue_subtotal' => float 652.03
          public 'revenue_tax' => float 107.98
          public 'revenue_shipping' => float 9.95
          public 'revenue_discount' => int 0
          public 'items' => int 11
          public 'avg_order_revenue' => float 220.66
          public 'conversion_rate' => string '0.82%' (length=5)

The data of both array entries are exactly the same, but when I'm doing the API-requests separately, without the use of Bulk-Request, the data is different, depending on the used segment.
The response of the separate request with 'segment=searches==0' is the same as above, just with one element in the array.

Separate request of 'segment>=1':
https://server.com/piwik/index.php?idSite=2&token_auth=TOKEN&module=API&format=json&method=Goals.get&period=day&date=2015-04-02,2015-04-03&idGoal=ecommerceOrder&segment=searches>=1&idSite=2

Response:


object(stdClass)[1428]
  public '2015-04-02' => 
    object(stdClass)[1088]
      public 'nb_conversions' => int 26
      public 'nb_visits_converted' => int 26
      public 'revenue' => float 3991.1
      public 'revenue_subtotal' => float 3885.8
      public 'revenue_tax' => float 665.04
      public 'revenue_shipping' => float 105.3
      public 'revenue_discount' => int 0
      public 'items' => int 254
      public 'avg_order_revenue' => float 153.5
      public 'conversion_rate' => string '6.47%' (length=5)
  public '2015-04-03' => 
    object(stdClass)[1089]
      public 'nb_conversions' => int 10
      public 'nb_visits_converted' => int 10
      public 'revenue' => float 776.72
      public 'revenue_subtotal' => float 714.17
      public 'revenue_tax' => float 128.57
      public 'revenue_shipping' => float 62.55
      public 'revenue_discount' => int 0
      public 'items' => int 45
      public 'avg_order_revenue' => float 77.67
      public 'conversion_rate' => string '6.94%' (length=5)

I would expect this response to be in array[0] of the Bulk-Request response.
Does anyone have a hint, if I'm using the bulk-request wrong or if there is a bug in the Piwik response API?

Thanks!

Regards,
Daniel

Hi Daniel,

can you try to URL Encode each of the URL in the bulk request?

(also make sure to URL Encode the Segment parameter value)

let me know if you still have an issue

Hi Matt,

Thanks for your advice!

It seems that I missed the seperate encoding of the segment.
I have just encoded all parameters after url[0] and url[1] once.

For anyone else, who have also troubles with segments, below is the working encoded url.
Note: The whole url itself is encoded once, the parameters within url[0] and url[1] are double-encoded and the segment parameter itself is triple-encoded.


https://server.com/?idSite=2&token_auth=TOKEN&module=API&format=json&method=API.getBulkRequest&urls%5B0%5D=method%3DGoals.get%26period%3Dday%26date%3D2015-04-15%252C2015-04-14%26idGoal%3DecommerceOrder%26segment%3Dsearches%25253E%25253D1&urls%5B1%5D=method%3DGoals.get%26period%3Dday%26date%3D2015-04-15%252C2015-04-14%26idGoal%3DecommerceOrder%26segment%3Dsearches%25253D%25253D0

Thanks again for your help!

Regards,
Daniel