« Back to Documentation Overview

campaignEmailStatsAIMAll – v1.3

 campaignEmailStatsAIMAll(string apikey, string cid, int start, int limit)

Given a campaign and correct paging limits, return the entire click and open history with timestamps, ordered by time, for every user a campaign was delivered to.

Section
Campaign Report Data
mcapi_campaignEmailStatsAIMAll.php
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
cid the campaign id to get stats for (can be gathered using campaigns())
start optional - for large data sets, the page number to start at - defaults to 1st page of data (page 0)
limit optional - for large data sets, the number of results to return - defaults to 100, upper limit set at 1000
Returns
array Array containing a total record count and data including the actions (opens and clicks) for each email, with timestamps
inttotalthe total number of records
arraydataeach record keyed by email address containing arrays of actions including:
stringactionThe action taken (open or click)
stringtimestampTime the action occurred
stringurlFor clicks, the URL that was clicked

Examples (1)

download example code

[1] mcapi_campaignEmailStatsAIMAll.php

  1. <?php
  2. /**
  3. This Example shows how to iterate through the AIM stats for every email address
  4. associated with a campaign and do some basic error checking.
  5. **/
  6.  
  7. // Include the MailChimp API code. Do Not Edit This!
  8. require_once 'inc/MCAPI.class.php';
  9. require_once 'inc/config.inc.php'; //contains apikey
  10.  
  11. $api = new MCAPI($apikey);
  12.  
  13. $limit = 5;
  14. for($i=0;$i<5;$i++){
  15. echo "====== Page $i : START ======\n";
  16. $allstats = $api->campaignEmailStatsAIMAll($campaignId, $i*$limit, $limit);
  17. if ($api->errorCode){
  18. echo "\n\tCode=".$api->errorCode;
  19. echo "\n\tMsg=".$api->errorMessage."\n";
  20. }
  21. if ($allstats['total']==0){
  22. echo "No more stats available!\n";
  23. }
  24. foreach($allstats['data'] as $email=>$stats){
  25. echo "[".$email."]\n";
  26. foreach($stats as $stat){
  27. echo "\t".$stat['action']." @ ".$stat['timestamp'];
  28. if ($stat['action']=='click'){
  29. echo "\n\tURL = ".$stat['url']."\n";
  30. } else {
  31. echo "\n";
  32. }
  33. }
  34. }
  35. echo "====== Page $i : END ======\n";
  36. }
  37.  
  38. ?>
  39.