« Back to Documentation OverviewcampaignEmailStatsAIMAll – v1.2
campaignEmailStatsAIMAll(string apikey, string cid, int start, integer 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.
| 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 position to start at - defaults to 0 (record 0) |
| limit | optional - for large data sets, the number of results to return - defaults to 100, upper limit set at 1000 |
| Returns | | array |
Array of structs containing actions (opens and clicks) for each email, with timestamps |
| Returned Fields | string | action | The action taken (open or click) | date | 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"; }
echo "No more stats available!\n"; }
foreach($allstats 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"; }
?>