As a Marketing Campaigns customer, you have access to rich statistics about your Single Sends and Automations. The Marketing Campaigns Statistics API allows you to retrieve these statistics programmatically. for detailed information about the statistics available, see the Marketing Campaigns Stats Overview.
These endpoints provide stats for Marketing Campaigns only. For stats related to event tracking, please see the Stats API.
This endpoint allows you to retrieve stats for an individual Single Send using a Single Send ID.
Multiple Single Send IDs can be retrieved using the "Get All Single Sends Stats" endpoint. Once you have an ID, this endpoint will return detailed stats for the Single Send specified.
You may constrain the stats returned using the start_date
and end_date
query string parameters. You can also use the group_by
and aggregated_by
query string parameters to further refine the stats returned.
Bearer <<YOUR_API_KEY_HERE>>
The ID of Single Send for which you want to retrieve stats.
Dictates how the stats are time-sliced. Currently, "total"
and "day"
are supported.
total
Possible values: day
total
Format: YYYY-MM-DD
. If this parameter is included, the stats' start date is included in the search.
2021-01-01
Format: YYYY-MM-DD
.If this parameter is included, the stats' end date is included in the search.
2021-12-31
IANA Area/Region string representing the timezone in which the stats are to be presented, e.g., "America/Chicago".
UTC
The number of elements you want returned on each page.
1
Maximum: 50
Default: 25
The stats endpoints are paginated. To get the next page, call the passed _metadata.next
URL. If _metadata.prev
doesn't exist, you're at the first page. Similarly, if _metadata.next
is not present, you're at the last page.
A/B Single Sends have multiple variation IDs and phase IDs. Including these additional fields allows further granularity of stats by these fields.
ab_variation
ab_phase
1const client = require('@sendgrid/client');2client.setApiKey(process.env.SENDGRID_API_KEY);34const id = "ZGkrHSypTsudrGkmdpJJ";5const queryParams = {6"start_date": "2021-01-01",7"end_date": "2021-12-31",8"timezone": "UTC",9"page_size": 2510};1112const request = {13url: `/v3/marketing/stats/singlesends/${id}`,14method: 'GET',15qs: queryParams16}1718client.request(request)19.then(([response, body]) => {20console.log(response.statusCode);21console.log(response.body);22})23.catch(error => {24console.error(error);25});