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 lets you retrieve click-tracking stats for one Single Send.
The stats returned list the URLs embedded in the specified Single Send and the number of clicks each one received.
Bearer <<YOUR_API_KEY_HERE>>
The ID of Single Send for which you want to retrieve link stats.
Optional
The number of elements you want returned on each page.
1
Maximum: 50
Default: 25
Optional
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.
Optional
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
Optional
Optional
test
send
This is the index of the link's location in the email contents.
1const client = require("@sendgrid/client");2client.setApiKey(process.env.SENDGRID_API_KEY);34const id = "ZGkrHSypTsudrGkmdpJJ";5const queryParams = {6page_size: 25,7};89const request = {10url: `/v3/marketing/stats/singlesends/${id}/links`,11method: "GET",12qs: queryParams,13};1415client16.request(request)17.then(([response, body]) => {18console.log(response.statusCode);19console.log(response.body);20})21.catch((error) => {22console.error(error);23});