{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Key Performance Statistics","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Query Mailjet /statcounters for delivery and engagement KPIs filtered by campaign, list, sender, or API key, with adjustable timing and resolution settings.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"key-performance-statistics","__idx":0},"children":["Key Performance Statistics"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/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)."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"stats-at-campaign-list-or-apikey-level","__idx":1},"children":["Stats at Campaign, List or APIKey Level"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SourceId=$Campaign_ID"]}," : Substitute $CampaignID with the ID of the Campaign you are interested in."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterSource=Campaign"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want to retrieve these key statistics but at a List level, use the $ListID as the value of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SourceID"]}," filter and enter List as the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterSource"]},". Keep in mind that retrieving list stats can only be done with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterTiming=Message&CounterResolution=Lifetime"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you need the stats at an API key level, make the request with ApiKey as the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterSource"]}," value. Keep in mind that you can only retrieve data for the ApiKey with which you are authenticated."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can also retrieve stats at a Sender level - simply set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterTiming"]}," filter to Message."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"event-based-vs-message-based-stats-timing","__idx":2},"children":["Event-based vs Message-based Stats Timing"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterTiming"]}," query parameter to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Message"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example","__idx":3},"children":["Example"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# View : Retrieve Key Delivery statistics for a Specific Campaign\ncurl -s \\\n\t-X GET \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/statcounters?SourceId=$Campaign_ID\\&CounterSource=Campaign\\&CounterTiming=Message\\&CounterResolution=Lifetime\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nView : Retrieve Key Delivery statistics for a Specific Campaign\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$filters = [\n  'SourceId' => '$Campaign_ID',\n  'CounterSource' => 'Campaign',\n  'CounterTiming' => 'Message',\n  'CounterResolution' => 'Lifetime'\n];\n$response = $mj->get(Resources::$Statcounters, ['filters' => $filters]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * View : Retrieve Key Delivery statistics for a Specific Campaign\n *\n */\nconst mailjet = require('node-mailjet').connect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_APIKEY_PRIVATE\n)\nconst request = mailjet.get('statcounters').request({\n  SourceId: '$Campaign_ID',\n  CounterSource: 'Campaign',\n  CounterTiming: 'Message',\n  CounterResolution: 'Lifetime',\n})\nrequest\n  .then(result => {\n    console.log(result.body)\n  })\n  .catch(err => {\n    console.log(err.statusCode)\n  })\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# View : Retrieve Key Delivery statistics for a Specific Campaign\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\nend\nvariable = Mailjet::Statcounters.all(source_id: \"$Campaign_ID\",\ncounter_source: \"Campaign\",\ncounter_timing: \"Message\",\ncounter_resolution: \"Lifetime\"\n)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nView : Retrieve Key Delivery statistics for a Specific Campaign\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nfilters = {\n  'SourceId': '$Campaign_ID',\n  'CounterSource': 'Campaign',\n  'CounterTiming': 'Message',\n  'CounterResolution': 'Lifetime'\n}\nresult = mailjet.statcounters.get(filters=filters)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.resource.Statcounters;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * View : Retrieve Key Delivery statistics for a Specific Campaign\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"));\n      request = new MailjetRequest(Statcounters.resource)\n                  .filter(Statcounters.SOURCEID, \"$Campaign_ID\")\n                  .filter(Statcounters.COUNTERSOURCE, \"Campaign\")\n                  .filter(Statcounters.COUNTERTIMING, \"Message\")\n                  .filter(Statcounters.COUNTERRESOLUTION, \"Lifetime\");\n      response = client.get(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nView : Retrieve Key Delivery statistics for a Specific Campaign\n*/\npackage main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.Statcounters\n\t_, _, err := mailjetClient.List(\"statcounters\", &data, Filter(\"SourceId\", \"$Campaign_ID\"), Filter(\"CounterSource\", \"Campaign\"), Filter(\"CounterTiming\", \"Message\"), Filter(\"CounterResolution\", \"Lifetime\"))\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      /// <summary>\n      /// View : Retrieve Key Delivery statistics for a Specific Campaign\n      /// </summary>\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"));\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Statcounters.Resource,\n         }\n         .Filter(Statcounters.Sourceid, \"$Campaign_ID\")\n         .Filter(Statcounters.Countersource, \"Campaign\")\n         .Filter(Statcounters.Countertiming, \"Message\")\n         .Filter(Statcounters.Counterresolution, \"Lifetime\");\n         MailjetResponse response = await client.GetAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response","__idx":4},"children":["API Response"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"Count\": 1,\n  \"Data\": [\n    {\n      \"APIKeyID\": 123456,\n      \"EventClickDelay\": 322,\n      \"EventClickedCount\": 6,\n      \"EventOpenDelay\": 739,\n      \"EventOpenedCount\": 11,\n      \"EventSpamCount\": 0,\n      \"EventUnsubscribedCount\": 2,\n      \"EventWorkflowExitedCount\": 0,\n      \"MessageBlockedCount\": 12,\n      \"MessageClickedCount\": 3,\n      \"MessageDeferredCount\": 0,\n      \"MessageHardBouncedCount\": 5,\n      \"MessageOpenedCount\": 8,\n      \"MessageQueuedCount\": 0,\n      \"MessageSentCount\": 15,\n      \"MessageSoftBouncedCount\": 0,\n      \"MessageSpamCount\": 0,\n      \"MessageUnsubscribedCount\": 2,\n      \"MessageWorkFlowExitedCount\": 0,\n      \"SourceID\": 654321,\n      \"Timeslice\": \"\",\n      \"Total\": 32\n    }\n  ],\n  \"Total\": 1\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterTiming"]}," query parameter to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Event"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"example-1","__idx":5},"children":["Example"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\ncurl -s \\\n\t-X GET \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3/REST/statcounters?SourceId=$Campaign_ID\\&CounterSource=Campaign\\&CounterTiming=Event\\&CounterResolution=Day\\&FromTS=123\\&ToTS=456\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nView : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));\n$filters = [\n  'SourceId' => '$Campaign_ID',\n  'CounterSource' => 'Campaign',\n  'CounterTiming' => 'Event',\n  'CounterResolution' => 'Day',\n  'FromTS' => '123',\n  'ToTS' => '456'\n];\n$response = $mj->get(Resources::$Statcounters, ['filters' => $filters]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n *\n */\nconst mailjet = require('node-mailjet').connect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_APIKEY_PRIVATE\n)\nconst request = mailjet.get('statcounters').request({\n  SourceId: '$Campaign_ID',\n  CounterSource: 'Campaign',\n  CounterTiming: 'Event',\n  CounterResolution: 'Day',\n  FromTS: 123,\n  ToTS: 456,\n})\nrequest\n  .then(result => {\n    console.log(result.body)\n  })\n  .catch(err => {\n    console.log(err.statusCode)\n  })\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\nend\nvariable = Mailjet::Statcounters.all(source_id: \"$Campaign_ID\",\ncounter_source: \"Campaign\",\ncounter_timing: \"Event\",\ncounter_resolution: \"Day\",\nfrom_ts: \"123\",\nto_ts: \"456\"\n)\np variable.attributes['Data']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nView : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret))\nfilters = {\n  'SourceId': '$Campaign_ID',\n  'CounterSource': 'Campaign',\n  'CounterTiming': 'Event',\n  'CounterResolution': 'Day',\n  'FromTS': '123',\n  'ToTS': '456'\n}\nresult = mailjet.statcounters.get(filters=filters)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.resource.Statcounters;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"));\n      request = new MailjetRequest(Statcounters.resource)\n                  .filter(Statcounters.SOURCEID, \"$Campaign_ID\")\n                  .filter(Statcounters.COUNTERSOURCE, \"Campaign\")\n                  .filter(Statcounters.COUNTERTIMING, \"Event\")\n                  .filter(Statcounters.COUNTERRESOLUTION, \"Day\")\n                  .filter(Statcounters.FROMTS, \"123\")\n                  .filter(Statcounters.TOTS, \"456\");\n      response = client.get(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nView : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n*/\npackage main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n\t\"github.com/mailjet/mailjet-apiv3-go/resources\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tvar data []resources.Statcounters\n\t_, _, err := mailjetClient.List(\"statcounters\", &data, Filter(\"SourceId\", \"$Campaign_ID\"), Filter(\"CounterSource\", \"Campaign\"), Filter(\"CounterTiming\", \"Event\"), Filter(\"CounterResolution\", \"Day\"), Filter(\"FromTS\", \"123\"), Filter(\"ToTS\", \"456\"))\n\tif err != nil {\n\t  fmt.Println(err)\n\t}\n\tfmt.Printf(\"Data array: %+v\\n\", data)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      /// <summary>\n      /// View : View campaign evolution statistics, based on daily timeslices and with a defined timeframe\n      /// </summary>\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"));\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Statcounters.Resource,\n         }\n         .Filter(Statcounters.Sourceid, \"$Campaign_ID\")\n         .Filter(Statcounters.Countersource, \"Campaign\")\n         .Filter(Statcounters.Countertiming, \"Event\")\n         .Filter(Statcounters.Counterresolution, \"Day\")\n         .Filter(Statcounters.Fromts, \"123\")\n         .Filter(Statcounters.Tots, \"456\");\n         MailjetResponse response = await client.GetAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-1","__idx":6},"children":["API Response"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"StatCounters\": {\n    \"Count\": 2,\n    \"Data\": [\n        {\n        \"APIKeyID\": \"320046\",\n        \"EventClickDelay\": \"200\",\n        \"EventClickCount\": \"3\",\n        \"EventOpenDelay\": \"20\",\n        \"EventOpenedCount\": \"4\",\n        \"EventSpamCount\": \"4\",\n        \"EventUnsubscribedCount\": \"5\",\n        \"EventWorkflowExitedCount\": \"5\",\n        \"MessageBlockedCount\": \"7\",\n        \"MessageClickedCount\": \"3\",\n        \"MessageDeferredCount\": \"2\",\n        \"MessageHardBouncedCount\": \"5\",\n        \"MessageOpenedCount\": \"5\",\n        \"MessageQueuedCount\": \"3\",\n        \"MessageSentCount\": \"2\",\n        \"MessageSoftBouncedCount\": \"7\",\n        \"MessageSpamCount\": \"5\",\n        \"MessageUnsubscribedCount\": \"1\",\n        \"MessageWorkflowExitedCount\": \"8\",\n        \"SourceID\": \"123456789\",\n        \"Timeslice\": \"456\",\n        \"Total\": \"50000\",\n        }\n        {\n        \"APIKeyID\": \"320046\",\n        \"EventClickDelay\": \"113\",\n        \"EventClickCount\": \"2\",\n        \"EventOpenDelay\": \"15\",\n        \"EventOpenedCount\": \"2\",\n        \"EventSpamCount\": \"0\",\n        \"EventUnsubscribedCount\": \"1\",\n        \"EventWorkflowExitedCount\": \"2\",\n        \"MessageBlockedCount\": \"3\",\n        \"MessageClickedCount\": \"1\",\n        \"MessageDeferredCount\": \"2\",\n        \"MessageHardBouncedCount\": \"2\",\n        \"MessageOpenedCount\": \"2\",\n        \"MessageQueuedCount\": \"3\",\n        \"MessageSentCount\": \"2\",\n        \"MessageSoftBouncedCount\": \"7\",\n        \"MessageSpamCount\": \"5\",\n        \"MessageUnsubscribedCount\": \"1\",\n        \"MessageWorkflowExitedCount\": \"8\",\n        \"SourceID\": \"123456789\",\n        \"Timeslice\": \"123\",\n        \"Total\": \"50000\",\n        }\n    ]\n  },\n        \"Total\": 2\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example-2","__idx":7},"children":["Example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example: A campaign is sent on Day1. There are 10 opens on Day2 and another 20 on Day3. If you use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CounterTiming=Event"]},", /statcounters will return the information on the open events, showing 10 opens on Day2 and 20 on Day3."]}]},"headings":[{"value":"Key Performance Statistics","id":"key-performance-statistics","depth":1},{"value":"Stats at Campaign, List or APIKey Level","id":"stats-at-campaign-list-or-apikey-level","depth":2},{"value":"Event-based vs Message-based Stats Timing","id":"event-based-vs-message-based-stats-timing","depth":2},{"value":"Example","id":"example","depth":3},{"value":"API Response","id":"api-response","depth":3},{"value":"Example","id":"example-1","depth":3},{"value":"API Response","id":"api-response-1","depth":3},{"value":"Example","id":"example-2","depth":4}],"frontmatter":{"title":"Mailjet Send Statistics","seo":{"description":"Query Mailjet /statcounters for delivery and engagement KPIs filtered by campaign, list, sender, or API key, with adjustable timing and resolution settings.","title":"Key Performance Statistics"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/statistics/key-performance-stats","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}