Skip to Content
MailerSend
Email API

Analytics

Track the performance of your transactional emails with MailerSend's Analytics API endpoint. Discover opens by country, email activity and more.

With these requests, get analytics on the activity of your emails like open rate, CTR, bounce rate, and other data for a dedicated list of recipients, domain names, or even tags.

Note on data retention

Analytics data is stored for up to 6 months.

Activity data by date

Retrieve data grouped by date, based on activity, with this GET request:

GET https://api.mailersend.com/v1/analytics/date

Request parameters

Query parameterTypeRequiredLimitationsDetails
domain_idstringno
recipient_id[]string[]noMax number of recipients: 50Not yet implemented
date_fromint|stringyesTimestamp is assumed to be UTC. Must be lower than date_to and no more than 183 days in the past. Rounded down to the start of the day.Unix timestamp: 1443651141, ISO 8601: 2015-10-01T00:00:00Z or 2015-10-01T00:00:00+00:00, or datetime: 2015-10-01 00:00:00
date_toint|stringyesTimestamp is assumed to be UTC. Must be higher than date_from and cannot be in the future. Rounded up to the end of the day.Unix timestamp: 1443661141, ISO 8601: 2015-10-01T23:59:59Z or 2015-10-01T23:59:59+00:00, or datetime: 2015-10-01 23:59:59
group_bystringnoPossible options: days, weeks, months, yearsDefault: days
tags[]string[]no
event[]string[]noPossible types: queued,sent,delivered,soft_bounced,
hard_bounced,deferred,opened,clicked,unsubscribed,
spam_complaints,survey_opened, survey_submitted,opened_unique,clicked_unique, suppressed
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\ActivityAnalyticsParams;
use MailerSend\Common\Constants;

$mailersend = new MailerSend(['api_key' => 'key']);

$activityAnalyticsParams = (new ActivityAnalyticsParams(1790121600, 1792713599))
                    ->setDomainId('domain_id')
                    ->setGroupBy(Constants::GROUP_BY_DAYS)
                    ->setTags(['tag'])
                    ->setEvent(['sent', 'delivered']);

$mailersend->analytics->activityDataByDate($activityAnalyticsParams);

More examples

Responses

Response keyTypeDetails
data.stats.*.datetimestampThe date will be at the start of the group_by unit (so start of day/week/month/year). Every date in the date range will be present, even if there are no events for that day.
data.stats.*.[event]intEvery queried event[] will be present in the response with a default value - 0

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "date_from": "1591228800",
    "date_to": "1591401599",
    "group_by": "days",
    "stats": [
      {
        "date": "1591228800",
        "queued": 0,
        "sent": 0,
        "delivered": 0,
        "opened": 0,
        "clicked": 0,
        "soft_bounced": 0,
        "hard_bounced": 0,
        "unsubscribed": 0,
        "spam_complaints": 0,
        "opened_unique": 0,
        "clicked_unique": 0,
	"survey_opened":0,
	"survey_submitted":0
      },
      {
        "date": "1591315200",
        "queued": 0,
        "sent": 0,
        "delivered": 0,
        "opened": 0,
        "clicked": 0,
        "soft_bounced": 0,
        "hard_bounced": 0,
        "unsubscribed": 0,
        "spam_complaints": 0,
        "opened_unique": 0,
        "clicked_unique": 0,
	"survey_opened":0,
	"survey_submitted":0
      }
    ]
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Opens by country

Retrieve data grouped by country, based on activity, with this GET request:

GET https://api.mailersend.com/v1/analytics/country

Request parameters

Query parameterTypeRequiredLimitationsDetails
domain_idstringno
recipient_id[]string[]noMax number of recipients: 50Not yet implemented
date_fromint|stringyesTimestamp is assumed to be UTC. Must be lower than date_to and no more than 183 days in the past. Rounded down to the start of the day.Unix timestamp: 1443651141, ISO 8601: 2015-10-01T00:00:00Z or 2015-10-01T00:00:00+00:00, or datetime: 2015-10-01 00:00:00
date_toint|stringyesTimestamp is assumed to be UTC. Must be higher than date_from and cannot be in the future. Rounded up to the end of the day.Unix timestamp: 1443661141, ISO 8601: 2015-10-01T23:59:59Z or 2015-10-01T23:59:59+00:00, or datetime: 2015-10-01 23:59:59
tags[]string[]no
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\OpensAnalyticsParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$opensAnalyticsParams = (new OpensAnalyticsParams(1790121600, 1792713599))
                    ->setDomainId('domain_id')
                    ->setTags(['tag']);

$mailersend->analytics->opensByCountry($opensAnalyticsParams);

More examples

Responses

Response keyTypeDetails
data.stats.*.namestring2 Letter code of the country. Will not be present if there's no data.
data.stats.*.countint

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "date_from": 1591228800,
    "date_to": 1591401599,
    "stats": [
      {
        "name": "LT",
        "count": 2
      }
    ]
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Opens by user-agent name

Retrieve data grouped by user-agent name (browser and operating system), based on activity, with this GET request:

GET https://api.mailersend.com/v1/analytics/ua-name

Request parameters

Query parameterTypeRequiredLimitationsDetails
domain_idstringno
recipient_id[]string[]noMax number of recipients: 50Not yet implemented
date_fromint|stringyesTimestamp is assumed to be UTC. Must be lower than date_to and no more than 183 days in the past. Rounded down to the start of the day.Unix timestamp: 1443651141, ISO 8601: 2015-10-01T00:00:00Z or 2015-10-01T00:00:00+00:00, or datetime: 2015-10-01 00:00:00
date_toint|stringyesTimestamp is assumed to be UTC. Must be higher than date_from and cannot be in the future. Rounded up to the end of the day.Unix timestamp: 1443661141, ISO 8601: 2015-10-01T23:59:59Z or 2015-10-01T23:59:59+00:00, or datetime: 2015-10-01 23:59:59
tags[]string[]no
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\OpensAnalyticsParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$opensAnalyticsParams = (new OpensAnalyticsParams(1790121600, 1792713599))
                    ->setDomainId('domain_id')
                    ->setTags(['tag']);

$mailersend->analytics->opensByUserAgentName($opensAnalyticsParams);

More examples

Responses

Response keyTypeDetails
data.stats.*.namestringUser Agent Name. Will not be present if there's no data.
data.stats.*.countint

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "date_from": 1591228800,
    "date_to": 1591401599,
    "stats": [
      {
        "name": "Chrome",
        "count": 2
      }
    ]
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

Opens by reading environment

Retrieve data grouped by the reading environment (webmail, mobile, desktop), based on activity, with this GET request:

GET https://api.mailersend.com/v1/analytics/ua-type

Request parameters

Query parameterTypeRequiredLimitationsDetails
domain_idstringno
recipient_id[]string[]noMax number of recipients: 50Not yet implemented
date_fromint|stringyesTimestamp is assumed to be UTC. Must be lower than date_to and no more than 183 days in the past. Rounded down to the start of the day.Unix timestamp: 1443651141, ISO 8601: 2015-10-01T00:00:00Z or 2015-10-01T00:00:00+00:00, or datetime: 2015-10-01 00:00:00
date_toint|stringyesTimestamp is assumed to be UTC. Must be higher than date_from and cannot be in the future. Rounded up to the end of the day.Unix timestamp: 1443661141, ISO 8601: 2015-10-01T23:59:59Z or 2015-10-01T23:59:59+00:00, or datetime: 2015-10-01 23:59:59
tags[]string[]no
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\OpensAnalyticsParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$opensAnalyticsParams = (new OpensAnalyticsParams(1790121600, 1792713599))
                    ->setDomainId('domain_id')
                    ->setTags(['tag']);

$mailersend->analytics->opensByReadingEnvironment($opensAnalyticsParams);

More examples

Responses

Response keyTypeDetails
data.stats.*.namestringOne of webmail, mobile,desktop. Will not be present if there's no data.
data.stats.*.countint

Valid

Response Code: 200 OK
Response Headers:
	content-type: application/json
{
  "data": {
    "date_from": 1591228800,
    "date_to": 1591401599,
    "stats": [
      {
        "name": "webmail",
        "count": 2
      },
      {
        "name": "mobile",
        "count": 2
      },
      {
        "name": "desktop",
        "count": 2
      }
    ]
  }
}

Error

Response Code: 422 Unprocessable Entity

See - Validation errors

On this page