campaignStats()

Campaign reports or major statistical data of campaign are obtained. In order to obtain more detailed data, additional functions have to be used.

campaignStats(string $cid) : array
Input parameters
  • cid - campaign ID
Information obtained

Campaign statistics is represented as an array that includes:

  • hard_bounces - hard bounces
  • soft_bounces - soft bounces
  • blocked_bounces - blocked bounces
  • temporary_bounces - temporary bounces
  • generic_bounces - generic bounces
  • unsubscribes - number of unsubscribes from this campaign
  • forwards - number of email forwards
  • opens - number of opens
  • last_open - date of the last open
  • unique_opens - number of unique opens
  • clicks - number of clicks on links
  • unique_clicks - number of unique clicks on links
  • last_click - date of the last click
  • users_who_clicked - subscribers that have clicked
  • emails_sent - number of sent emails

Examples

mgapi_campaignStats.php
campaignStats($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignStats()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Stats for " . $cid . "\n";
    foreach ($retval as $k => $v) {
        echo "\t" . $k . " => " . $v . "\n";
    }
}
xml-rpc_campaignStats.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignStats', array($v));
$c = new xmlrpc_client($apiUrl["path"], $apiUrl['host'], 80);
$c->setDebug($debug);
$r = &$c->send($f);
 
header("Content-Type: text/plain");
if (!$r->faultCode()) {
    $retval = php_xmlrpc_decode($r->value());
    echo "Stats for " . $campaignId . "\n";
    foreach ($retval as $k => $v) {
        echo "\t" . $k . " => " . $v . "\n";
    }
} else {
    echo "Unable to run campaignStats()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignStats.py
from lib.config import * #contains apikey
from lib.MGAPI import MGAPI
 
# This Example shows how to ping using the MGAPI.php class and do some basic error checking.
 
api = MGAPI(apikey)
 
cid = campaignId
 
retval = api.campaignStats(cid)
if api.errorCode:
    print "Unable to load campaignStats()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Stats for ", cid
    for k,v in retval.items():
        print "\t", k, " => ", v

© 2010-2017 Mailigen. All rights reserved.