campaignStats(string apikey, string cid)
Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
| Section | Campaign Stats |
|---|
| Parameters | |
|---|---|
| apikey | a valid API Key for your user account. Get by calling Get by visiting your API dashboard |
| cid | the campaign id to pull stats for (can be gathered using campaigns()) |
| Returns | |
|---|---|
| array | struct of the statistics for this campaign |
| Returned Fields | integer | syntax_errors | Number of email addresses in campaign that had syntactical errors. | integer | hard_bounces | Number of email addresses in campaign that hard bounced. | integer | soft_bounces | Number of email addresses in campaign that soft bounced. | integer | unsubscribes | Number of email addresses in campaign that unsubscribed. | integer | abuse_reports | Number of email addresses in campaign that reported campaign for abuse. | integer | forwards | Number of times email was forwarded to a friend. | integer | forwards_opens | Number of times a forwarded email was opened. | integer | opens | Number of times the campaign was opened. | date | last_open | Date of the last time the email was opened. | integer | unique_opens | Number of people who opened the campaign. | integer | clicks | Number of times a link in the campaign was clicked. | integer | unique_clicks | Number of unique recipient/click pairs for the campaign. | date | last_click | Date of the last time a link in the email was clicked. | integer | users_who_clicked | Number of unique recipients who clicked on a link in the campaign. | integer | emails_sent | Number of email addresses campaign was sent to. |
|---|
[1] mcapi_campaignStats.php
<?php /** This Example shows how to pull basic stats for a Campaign Tests via the MCAPI class. **/ require_once 'inc/MCAPI.class.php'; require_once 'inc/config.inc.php'; //contains apikey $retval = $api->campaignStats($campaignId); if ($api->errorCode){ } else { foreach($retval as $k=>$v){ } }
[2] xml-rpc_campaignStats.php
<?php /** This Example shows how to using XML-RPC to grab the Stats for a Campaign you previously sent Note that we are using the PEAR XML-RPC client and recommend others do as well. **/ require_once 'XML/RPC2/Client.php'; require_once 'inc/config.inc.php'; try { $result = $client->campaignStats($apikey, $campaignId); foreach($result as $k=>$v){ } } catch (XML_RPC2_FaultException $e){ }