Back to Documentation Overview

campaignStats

public static 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 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.

Examples (2)

download example code

[1] mcapi_campaignStats.php

  1. <?php
  2. /**
  3. This Example shows how to pull basic stats for a Campaign Tests
  4. via the MCAPI class.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $retval = $api->campaignStats($campaignId);
  12.  
  13. if ($api->errorCode){
  14. echo "Unable to Load Campaign Stats!";
  15. echo "\n\tCode=".$api->errorCode;
  16. echo "\n\tMsg=".$api->errorMessage."\n";
  17. } else {
  18. echo "Stats for ".$campaignId."\n";
  19. foreach($retval as $k=>$v){
  20. echo "\t".$k." => ".$v."\n";
  21. }
  22. }
  23.  

[2] xml-rpc_campaignStats.php

  1. <?php
  2. /**
  3. This Example shows how to using XML-RPC to grab the Stats for a Campaign you
  4. previously sent
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11.  
  12. $result = $client->campaignStats($apikey, $campaignId);
  13.  
  14. echo "SUCCESS! \n";
  15. echo "Stats for ".$campaignId."\n";
  16. foreach($result as $k=>$v){
  17. echo "\t".$k." => ".$v."\n";
  18. }
  19. } catch (XML_RPC2_FaultException $e){
  20. echo "ERROR!!!!\n";
  21. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  22. }
  23. echo "\n";
  24.  
  25.  
Add New Note User Contributed Notes for campaignStats
No notes, yet... Will you be the first??