Chilkat Online Tools

SQL Server / Braze Endpoints / Send Analytics

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'campaign_id', '{{campaign_identifier}}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'send_id', '{{send_identifier}}'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'length', 30
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'ending_at', '2014-12-10T23:59:59-05:00'

    -- Adds the "Authorization: Bearer {{api_key}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{api_key}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://rest.iad-01.braze.com/sends/data_series', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams


END
GO

Curl Command

curl -G -d "campaign_id=%7B%7Bcampaign_identifier%7D%7D"
	-d "send_id=%7B%7Bsend_identifier%7D%7D"
	-d "length=30"
	-d "ending_at=2014-12-10T23%3A59%3A59-05%3A00"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/sends/data_series

Postman Collection Item JSON

{
  "name": "Send Analytics",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/sends/data_series?campaign_id={{campaign_identifier}}&send_id={{send_identifier}}&length=30&ending_at=2014-12-10T23:59:59-05:00",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "sends",
        "data_series"
      ],
      "query": [
        {
          "key": "campaign_id",
          "value": "{{campaign_identifier}}",
          "description": "(Required) String\n\nCampaign API identifier."
        },
        {
          "key": "send_id",
          "value": "{{send_identifier}}",
          "description": "(Required) String\n\nSend API identifier."
        },
        {
          "key": "length",
          "value": "30",
          "description": "(Required) Integer\n\nMaximum number of days before `ending_at` to include in the returned series. Must be between 1 and 100 inclusive."
        },
        {
          "key": "ending_at",
          "value": "2014-12-10T23:59:59-05:00",
          "description": "(Optional) Datetime ISO 8601 string\n\nDate on which the data series should end. Defaults to time of the request."
        }
      ]
    },
    "description": "This endpoint allows you to retrieve a daily series of various stats for a tracked `send_id`. Braze stores send analytics for 14 days after the send.\n\nCampaign conversions will be attributed towards the most recent send id that a given user has received from the campaign.\n\n> The `send_id` is only generated for API campaign sends targeting segments, connected audiences or broadcasts. When relevant, the `send_id` is included in response for the `messages/send`, `messages/schedule`, `campaign/trigger/send` and `campaign/trigger/schedule` endpoints.\n\n### Components Used\n- [Campaign Identifier](https://www.braze.com/docs/api/identifier_types/)\n\n### Send Analytics Endpoint API Response\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n            \"variation_name\": (string) variation name,\n            \"sent\": (int) the number of sends,\n            \"delivered\": (int) the number of messages successfully delivered,\n            \"undelivered\": (int) the number of undelivered,\n            \"delivery_failed\": (int) the number of rejected,\n            \"direct_opens\": (int) the number of direct opens,\n            \"total_opens\": (int) the number of total opens,\n            \"bounces\": (int) the number of bounces,\n            \"body_clicks\": (int) the number of body clicks,\n            \"revenue\": (float) the number of dollars of revenue (USD),\n            \"unique_recipients\": (int) the number of unique recipients,\n            \"conversions\": (int) the number of conversions,\n            \"conversions_by_send_time\": (int) the number of conversions,\n            \"conversions1\": (int, optional) the number of conversions for the second conversion event,\n            \"conversions1_by_send_time\": (int, optional) the number of conversions for the second conversion event by send time,\n            \"conversions2\": (int, optional) the number of conversions for the third conversion event,\n            \"conversions2_by_send_time\": (int, optional) the number of conversions for the third conversion event by send time,\n            \"conversions3\": (int, optional) the number of conversions for the fourth conversion event,\n            \"conversions3_by_send_time\": (int, optional) the number of conversions for the fourth conversion event by send time\n          }\n        ]\n      },\n      \"conversions_by_send_time\": 0,\n      \"conversions1_by_send_time\": 0,\n      \"conversions2_by_send_time\": 0,\n      \"conversions3_by_send_time\": 0,\n      \"conversions\": 0,\n      \"conversions1\": 0,\n      \"conversions2\": 0,\n      \"conversions3\": 0,\n      \"unique_recipients\": 1,\n      \"revenue\": 0\n    }\n  ],\n  \"message\": \"success\"\n}\n```"
  },
  "response": [
  ]
}