Chilkat Online Tools

PowerBuilder / Braze Endpoints / Custom Events Analytics

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("event","event_name")
loo_QueryParams.UpdateInt("length",24)
loo_QueryParams.UpdateString("unit","hour")
loo_QueryParams.UpdateString("ending_at","2014-12-10T23:59:59-05:00")
loo_QueryParams.UpdateString("app_id","{{app_identifier}}")
loo_QueryParams.UpdateString("segment_id","{{segment_identifier}}")

// Adds the "Authorization: Bearer {{api_key}}" header.
loo_Http.AuthToken = "{{api_key}}"

loo_Resp = loo_Http.QuickRequestParams("GET","https://rest.iad-01.braze.com/events/data_series",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_QueryParams

Curl Command

curl -G -d "event=event_name"
	-d "length=24"
	-d "unit=hour"
	-d "ending_at=2014-12-10T23%3A59%3A59-05%3A00"
	-d "app_id=%7B%7Bapp_identifier%7D%7D"
	-d "segment_id=%7B%7Bsegment_identifier%7D%7D"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/events/data_series

Postman Collection Item JSON

{
  "name": "Custom Events Analytics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/events/data_series?event=event_name&length=24&unit=hour&ending_at=2014-12-10T23:59:59-05:00&app_id={{app_identifier}}&segment_id={{segment_identifier}}",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "events",
        "data_series"
      ],
      "query": [
        {
          "key": "event",
          "value": "event_name",
          "description": "(Required) String\n\nThe name of the custom event for which to return analytics "
        },
        {
          "key": "length",
          "value": "24",
          "description": "(Required) Integer\n\nMax number of units (days or hours) before ending_at to include in the returned series - must be between 1 and 100 inclusive"
        },
        {
          "key": "unit",
          "value": "hour",
          "description": "(Optional) String\n\nUnit of time between data points - can be \"day\" or \"hour\" (defaults to \"day\")"
        },
        {
          "key": "ending_at",
          "value": "2014-12-10T23:59:59-05:00",
          "description": "(Optional) DateTime (ISO 8601 string)\n\nPoint in time when the data series should end - defaults to time of the request"
        },
        {
          "key": "app_id",
          "value": "{{app_identifier}}",
          "description": "(Optional) String\n\nApp API identifier retrieved from the Developer Console to limit analytics to a specific app"
        },
        {
          "key": "segment_id",
          "value": "{{segment_identifier}}",
          "description": "(Optional) String\n\nSegment API identifier indicating the analytics enabled segment for which event analytics should be returned"
        }
      ]
    },
    "description": "This endpoint allows you to retrieve a series of the number of occurrences of a custom event in your app over a designated time period.\n\n### Components Used\n-[Segment Identifier](https://www.braze.com/docs/api/identifier_types/)\n\n\n## Response\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n    \"message\": (required, string) the status of the export, returns 'success' when completed without errors,\n    \"data\" : [\n        {\n            \"time\" : (string) point in time - as ISO 8601 extended when unit is \"hour\" and as ISO 8601 date when unit is \"day\",\n            \"count\" : (int)\n        },\n        ...\n    ]\n}\n```\n\n### Fatal Error Response Codes\nThe following status codes and associated error messages will be returned if your request encounters a fatal error. Any of these error codes indicate that no data will be processed.\n\n| Error Code       | Reason / Cause                                                   |\n| ---------------- | ---------------------------------------------------------------- |\n| 400 Bad Request  | Bad Syntax                                                       |\n| 401 Unauthorized | Unknown or missing REST API Key                                  |\n| 429 Rate Limited | Over rate limit                                                  |\n| 5XX              | Internal server error, you should retry with exponential backoff |"
  },
  "response": [
  ]
}