REST API v4: GET statistics (Marketing Suite template)

You can retrieve the statistics of a Marketing Suite template by sending an HTTP GET request to the following URL:

https://api.copernica.com/v4/draganddrop/template/$id/statistics

Where the $id should be replaced with the ID of the template.

Available parameters

  • begintime: Start date (and time) for the statistics (YYYY-MM-DD HH:MM:SS format).
  • endtime: End date (and time) for the statistics (YYYY-MM-DD HH:MM:SS format).

Return value

Fields

The following fields are available in the JSON object:

  • destinations: The number of destinations for this mailing.
  • abuses: An array with field 'total' for the total number of abuses.
  • clicks: An array with fields 'total' and 'unique' for the total number of clicks and number of unique clicks respectively.
  • deliveries: An array with field 'total' for the total number of deliveries.
  • errors: An array with field 'total' for the total number of errors.
  • impressions: An array with fields 'total' and 'unique' for the total number impressions and number of unique impressions respectively.
  • retries: An array with field 'total' for the total number of retries.
  • unsubscribes: An array with field 'total' and 'unique' for the total number of unsubscribes.

Example

The JSON output will look something like this:

{  
   "destinations":"527347",
   "abuses":{  
      "total":0
   },
   "clicks":{  
      "total":0,
      "unique":0
   },
   "deliveries":{  
      "total":39
   },
   "errors":{  
      "total":5
   },
   "impressions":{  
      "total":4,
      "unique":1
   },
   "retries":{  
      "total":30
   },
   "unsubscribes":{  
      "total":3,
      "unique":2
   }
}

PHP example

This script demonstrates how to use this API method:

// dependencies
require_once('CopernicaRestAPI.php');

// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 4);

// set the period
$data = array(
    'begintime' => "2019-01-01 00:00:00", 
    'endtime'   => "2019-02-01 00:00:00"
);

// execute the call
print_r($api->get("draganddrop/template/{$templateID}/statistics/", $data));

This example requires the REST API class.

More information