« Back to Documentation OverviewcampaignEmailStatsAIMAll – 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 |
| Parameters | mcapi_campaignEmailStatsAIMAll.php| 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
| int | total | the total number of records
| | array | data | each record keyed by email address containing arrays of actions including:
| string | action | The action taken (open or click)
| | string | timestamp | Time the action occurred
| | string | url | For clicks, the URL that was clicked
| | |
Examples (1)
download example code
[1] mcapi_campaignEmailStatsAIMAll.php
<?php
/**
This Example shows how to iterate through the AIM stats for every email address
associated with a campaign and do some basic error checking.
**/
// Include the MailChimp API code. Do Not Edit This!
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$limit = 5;
for($i=0;$i<5;$i++){
echo "====== Page $i : START ======\n"; $allstats = $api->campaignEmailStatsAIMAll($campaignId, $i*$limit, $limit);
if ($api->errorCode){
echo "\n\tCode=".$api->errorCode; echo "\n\tMsg=".$api->errorMessage."\n"; }
if ($allstats['total']==0){
echo "No more stats available!\n"; }
foreach($allstats['data'] as $email=>$stats){
foreach($stats as $stat){
echo "\t".$stat['action']." @ ".$stat['timestamp']; if ($stat['action']=='click'){
echo "\n\tURL = ".$stat['url']."\n"; } else {
}
}
}
echo "====== Page $i : END ======\n"; }
?>