Skip to content

Key Performance Statistics

The /statcounters resource is a multifunctional tool that allows you to view stats through various prisms while varying the Source (API Key, Campaign, List or Sender), the Timing (Event-based or Message-based counters' timestamp), or the Timeframe (Lifetime, Day, Hour, 5 Minutes).

Stats at Campaign, List or APIKey Level

The /statcounters code samples available in the following sections are done at a campaign level, which is indicated by the use of the following filters in the calls:

  • SourceId=$Campaign_ID : Substitute $CampaignID with the ID of the Campaign you are interested in.
  • CounterSource=Campaign

If you want to retrieve these key statistics but at a List level, use the $ListID as the value of the SourceID filter and enter List as the CounterSource. Keep in mind that retrieving list stats can only be done with CounterTiming=Message&CounterResolution=Lifetime.

If you need the stats at an API key level, make the request with ApiKey as the CounterSource value. Keep in mind that you can only retrieve data for the ApiKey with which you are authenticated.

You can also retrieve stats at a Sender level - simply set Sender as the CounterSource value and enter the sender ID as the value of the SourceID filter. Sender statistics can only be retrieved as message-based, so you'll need to set the value of the CounterTiming filter to Message.

Event-based vs Message-based Stats Timing

The /statcounters resource allows you to retrieve information both based on the message sending time (message-based) and on the timing of the event occurrence (event-based).

Message-based stats allow you to easily view the success of your sending by having the delivery rates / contact engagement details linked to the sending time. To retrieve message-based statistics, set the value of the CounterTiming query parameter to Message.

Example

# View : Retrieve Key Delivery statistics for a Specific Campaign
curl -s \
	-X GET \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/REST/statcounters?SourceId=$Campaign_ID\&CounterSource=Campaign\&CounterTiming=Message\&CounterResolution=Lifetime

API Response

{
  "Count": 1,
  "Data": [
    {
      "APIKeyID": 123456,
      "EventClickDelay": 322,
      "EventClickedCount": 6,
      "EventOpenDelay": 739,
      "EventOpenedCount": 11,
      "EventSpamCount": 0,
      "EventUnsubscribedCount": 2,
      "EventWorkflowExitedCount": 0,
      "MessageBlockedCount": 12,
      "MessageClickedCount": 3,
      "MessageDeferredCount": 0,
      "MessageHardBouncedCount": 5,
      "MessageOpenedCount": 8,
      "MessageQueuedCount": 0,
      "MessageSentCount": 15,
      "MessageSoftBouncedCount": 0,
      "MessageSpamCount": 0,
      "MessageUnsubscribedCount": 2,
      "MessageWorkFlowExitedCount": 0,
      "SourceID": 654321,
      "Timeslice": "",
      "Total": 32
    }
  ],
  "Total": 1
}

Event-based stats allow you to view the spread of events over time after the initial sending, helping you identify when recipients were most active / engaged with your campaigns. To retrieve event-based statistics, set the value of the CounterTiming query parameter to Event.

Example

# View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe
curl -s \
	-X GET \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/REST/statcounters?SourceId=$Campaign_ID\&CounterSource=Campaign\&CounterTiming=Event\&CounterResolution=Day\&FromTS=123\&ToTS=456

API Response

{
  "StatCounters": {
    "Count": 2,
    "Data": [
        {
        "APIKeyID": "320046",
        "EventClickDelay": "200",
        "EventClickCount": "3",
        "EventOpenDelay": "20",
        "EventOpenedCount": "4",
        "EventSpamCount": "4",
        "EventUnsubscribedCount": "5",
        "EventWorkflowExitedCount": "5",
        "MessageBlockedCount": "7",
        "MessageClickedCount": "3",
        "MessageDeferredCount": "2",
        "MessageHardBouncedCount": "5",
        "MessageOpenedCount": "5",
        "MessageQueuedCount": "3",
        "MessageSentCount": "2",
        "MessageSoftBouncedCount": "7",
        "MessageSpamCount": "5",
        "MessageUnsubscribedCount": "1",
        "MessageWorkflowExitedCount": "8",
        "SourceID": "123456789",
        "Timeslice": "456",
        "Total": "50000",
        }
        {
        "APIKeyID": "320046",
        "EventClickDelay": "113",
        "EventClickCount": "2",
        "EventOpenDelay": "15",
        "EventOpenedCount": "2",
        "EventSpamCount": "0",
        "EventUnsubscribedCount": "1",
        "EventWorkflowExitedCount": "2",
        "MessageBlockedCount": "3",
        "MessageClickedCount": "1",
        "MessageDeferredCount": "2",
        "MessageHardBouncedCount": "2",
        "MessageOpenedCount": "2",
        "MessageQueuedCount": "3",
        "MessageSentCount": "2",
        "MessageSoftBouncedCount": "7",
        "MessageSpamCount": "5",
        "MessageUnsubscribedCount": "1",
        "MessageWorkflowExitedCount": "8",
        "SourceID": "123456789",
        "Timeslice": "123",
        "Total": "50000",
        }
    ]
  },
        "Total": 2
}

Example

Example: A campaign is sent on Day1. There are 10 opens on Day2 and another 20 on Day3. If you use CounterTiming=Message in the call, the returned result will be for the messages that were opened, thus showing 30 opens on Day1. If you use CounterTiming=Event, /statcounters will return the information on the open events, showing 10 opens on Day2 and 20 on Day3.