Campaign statistics

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

campaignHardBounces()

Data is obtained about hard bounces of a particular campaign.

campaignHardBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignHardBounces.php
campaignHardBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignHardBounces()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}
xml-rpc_campaignHardBounces.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(1000)
                ),
                'struct');
$f = new xmlrpcmsg('campaignHardBounces', 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 "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
} else {
    echo "Unable to run campaignHardBounces()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignHardBounces.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
start = 0
limit = 1000
 
retval = api.campaignHardBounces(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignHardBounces()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "E-mails returned: %d" % (len(retval))
    for email in retval:
        print "\t", email

campaignSoftBounces()

Data is obtained about soft bounces of a particular campaign.

campaignSoftBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignSoftBounces.php
campaignSoftBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignSoftBounces()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}
xml-rpc_campaignSoftBounces.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(1000)
                ),
                'struct');
$f = new xmlrpcmsg('campaignSoftBounces', 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 "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
} else {
    echo "Unable to run campaignSoftBounces()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignSoftBounces.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
start = 0
limit = 1000
 
retval = api.campaignSoftBounces(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignSoftBounces()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "E-mails returned: %d" % (len(retval))
    for email in retval:
        print "\t", email

campaignBlockedBounces()

Data is obtained about blocked bounces of a particular campaign.

campaignBlockedBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignBlockedBounces.php
campaignBlockedBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignBlockedBounces()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}

campaignTemporaryBounces()

Data is obtained about temporary bounces of a particular campaign.

campaignTemporaryBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignTemporaryBounces.php
campaignTemporaryBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignTemporaryBounces()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}

campaignGenericBounces()

Data is obtained about generic bounces of a particular campaign.

campaignGenericBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignGenericBounces.php
campaignGenericBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignGenericBounces()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}

campaignClickStats()

List of links on which receivers have clicked is obtained, as well as the number of total clicks and unique clicks.

campaignClickStats(string $cid) : struct
Input parameters
  • cid - campaign ID
Information obtained

Array of links. Each link is stored as a key of resulting array and its corresponding value is an array consisting of:

  • clicks - number of clicks
  • unique - unique clicks

Examples

mgapi_campaignClickStats.php
campaignClickStats($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignClickStats()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    if (sizeof($retval) == 0) {
        echo "No stats for this campaign yet!\n";
    } else {
        foreach ($retval as $url => $detail) {
            echo "URL: " . $url . "\n";
            echo "\tClicks = " . $detail['clicks'] . "\n";
            echo "\tUnique Clicks = " . $detail['unique'] . "\n";
        }
    }
}
xml-rpc_campaignClickStats.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(1000)
                ),
                'struct');
$f = new xmlrpcmsg('campaignClickStats', 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());
    if (sizeof($stats) == 0) {
        echo "No stats for this campaign yet!\n";
    } else {
        foreach ($retval as $url => $detail) {
            echo "URL: " . $url . "\n";
            echo "\tClicks = " . $detail['clicks'] . "\n";
            echo "\tUnique Clicks = " . $detail['unique'] . "\n";
        }
    }
} else {
    echo "Unable to run campaignClickStats()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignClickStats.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.campaignClickStats(cid)
if api.errorCode:
    print "Unable to load campaignClickStats()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    if len(retval) == 0:
        print "No stats for this campaign yet!"
    else:
        for url, detail in retval.items():
            print "URL: %s" % (url)
            print "\tClicks = %s" % (detail['clicks'])
            print "\tUnique Clicks = %s" % (detail['unique'])

campaignEmailDomainPerformance()

List of recipients’ email domains (array) is obtained, as well as statistics about each of these email domains.

campaignEmailDomainPerformance(string $cid) : array

Input parameters
  • cid - campaign ID
Obtained information

Array of domains. Each domain is represented as an array consisting of:

  • domain - domain name
  • total_sent - number of sent emails (for the whole campaign)
  • emails - number of sent emails (for a specific domain)
  • bounces - number of hard bounces
  • opens - number of unique opens
  • clicks - number of unique clicks
  • unsubs - number of unsubscribes
  • delivered - number of delivered emails
  • emails_pct - percentage of sent emails
  • bounces_pct - percentage of bounced emails
  • opens_pct - percentage of open rate
  • clicks_pct - percentage of click rate
  • unsubs_pct - percentage of unsubscribe rate

Examples

mgapi_campaignEmailDomainPerformance.php
campaignEmailDomainPerformance($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignEmailDomainPerformance()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    if (sizeof($retval) == 0) {
        echo "No Email Domain stats yet!\n";
    } else {
        foreach ($retval as $domain) {
            echo $domain['domain'] . "\n";
            echo "\tEmails: " . $domain['emails'] . "\n";
            echo "\tOpens: " . $domain['opens'] . "\n";
            echo "\tClicks: " . $domain['clicks'] . "\n";
        }
    }
}
xml-rpc_campaignEmailDomainPerformance.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(1000)
                ),
                'struct');
$f = new xmlrpcmsg('campaignEmailDomainPerformance', 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());
    if (sizeof($retval) == 0) {
        echo "No Email Domain stats yet!\n";
    } else {
        foreach ($retval as $domain) {
            echo $domain['domain'] . "\n";
            echo "\tEmails: " . $domain['emails'] . "\n";
            echo "\tOpens: " . $domain['opens'] . "\n";
            echo "\tClicks: " . $domain['clicks'] . "\n";
        }
    }
} else {
    echo "Unable to run campaignEmailDomainPerformance()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignEmailDomainPerformance.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.campaignEmailDomainPerformance(cid)
if api.errorCode:
    print "Unable to load campaignEmailDomainPerformance()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    if len(retval) == 0:
        print "No Email Domain stats yet!"
    else:
        for domain in retval:
            print domain['domain']
            print "\tEmails: ", domain['emails']
            print "\tOpens: ", domain['opens']
            print "\tClicks: ", domain['clicks']

campaignUnsubscribes()

Unsubscribed emails are found.

campaignUnsubscribes(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignUnsubscribes.php
campaignUnsubscribes($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignUnsubscribes()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
}
xml-rpc_campaignUnsubscribes.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(1000)
                ),
                'struct');
$f = new xmlrpcmsg('campaignUnsubscribes', 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 "E-mails returned: " . sizeof($retval) . "\n";
    foreach ($retval as $email) {
        echo "\t" . $email . "\n";
    }
} else {
    echo "Unable to run campaignUnsubscribes()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignUnsubscribes.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
start = 0
limit = 1000
 
retval = api.campaignUnsubscribes(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignUnsubscribes()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "E-mails returned: %d" % (len(retval))
    for email in retval:
        print "\t", email

campaignGeoOpens()

Data is obtained about countries in which emails were opened.List (array) of countries and number of opened emails in each country is returned.

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

Array of countries. Each country is represented as an array consisting of:

  • code - country code in ISO3166 format (2 symbols)
  • name - name of country
  • opens - number of opened emails

Examples

mgapi_campaignGeoOpens.php
campaignGeoOpens($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignGeoOpens()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Open from " . sizeof($retval) . " countries:\n";
    foreach ($retval as $country) {
        echo "\t" . $country['code'] . "\t" . $country['name'] . "\t" . $country['opens'] . "\n";
    }
}
xml-rpc_campaignGeoOpens.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignGeoOpens', 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 "Open from " . sizeof($retval) . " countries:\n";
    foreach ($retval as $country) {
        echo "\t" . $country['code'] . "\t" . $country['name'] . "\t" . $country['opens'] . "\n";
    }
} else {
    echo "Unable to run campaignGeoOpens()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignGeoOpens.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.campaignGeoOpens(cid)
if api.errorCode:
    print "Unable to load campaignGeoOpens()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Open from %d countries:" % (len(retval))
    for country in retval:
        print "\t", country['code'], "\t", country['name'], "\t", country['opens']

campaignForwardStats()

Data is obtained about forwarded emails for a particular campaign if Mailigen forwarding code is embedded in the campaign.

campaignForwardStats(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID
  • start - page number starting from which selection will be made (optional). Default value is 0.
  • limit - number of results returned in one page (optional). Default value is 1000. Maximum allowable value is 15000.
Information obtained
  • email list (array)

Examples

mgapi_campaignForwardStats.php
campaignForwardStats($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignForwardStats()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    if (sizeof($retval) == 0) {
        echo "No stats for this campaign yet!\n";
    } else {
        foreach ($retval as $email => $detail) {
            echo "E-mail: " . $email . "\n";
            echo "\tFriend name = " . $detail['friend_name'] . "\n";
        }
    }
}
xml-rpc_campaignForwardStats.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(25)
                ),
                'struct');
$f = new xmlrpcmsg('campaignForwardStats', 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());
    if (sizeof($retval) == 0) {
        echo "No stats for this campaign yet!\n";
    } else {
        foreach ($retval as $email => $detail) {
            echo "E-mail: " . $email . "\n";
            echo "\tFriend name = " . $detail['friend_name'] . "\n";
        }
    }
} else {
    echo "Unable to run campaignForwardStats()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
xml-rpc_campaignForwardStats.php
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
start = 0
limit = 1000
 
retval = api.campaignForwardStats(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignForwardStats()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    if len(retval) == 0:
        print "No stats for this campaign yet!"
    else:
        for email, detail in retval.items():
            print "E-mail: ", email
            print "\tFriend name = ", detail['friend_name']

campaignOpened()

Data is obtained about opened emails for a particular campaign.

campaignOpened(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID/li>
  • start - page number starting from which selection will be made (optional). Default value is 0./li>
  • limit - number of results returned in one page (optional). Default value is 25. Maximum allowable value is 50./li>
Information obtained

Information about opened emails is represented as an array that includes:

  • total - total number of opened emails
  • data - detailed information about opened emails. Array consisting of:
    • email - email address
    • count - number of times opened

Examples

mgapi_campaignOpened.php
campaignOpened($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load campaignOpened()!";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    if (sizeof($retval)==0){
        echo "No stats for this campaign yet!\n";
    } else {
        echo "Total: ".$retval['total']."\n";
        foreach($retval['data'] as $data){
            echo "\tE-mail: ".$data['email']."\n";
            echo "\tCount: ".$data['count']."\n\n";
        }
    }
}

campaignNotOpened()

Data is obtained about not opened emails for a particular campaign.

campaignNotOpened(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID/li>
  • start - page number starting from which selection will be made (optional). Default value is 0./li>
  • limit - number of results returned in one page (optional). Default value is 25. Maximum allowable value is 50./li>
Information obtained

Information about not opened emails is represented as an array that includes:

  • total - total number of not opened emails
  • data - array consisting of not opened email addresses

Examples

mgapi_campaignNotOpened.php
campaignNotOpened($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load campaignNotOpened()!";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    if (sizeof($retval)==0){
        echo "No stats for this campaign yet!\n";
    } else {
        echo "Total: ".$retval['total']."\n";
        foreach($retval['data'] as $email){
            echo "\tE-mail: ".$email."\n";
        }
    }
}

campaignBounceMessages()

Messages are received from email recipient server in cases email was hard bounced. Reports are obtained only about emails that are not older than 30 days. Email list with additional parameters is returned.

campaignBounceMessages(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - campaign ID/li>
  • start - page number starting from which selection will be made (optional). Default value is 0./li>
  • limit - number of results returned in one page (optional). Default value is 25. Maximum allowable value is 50./li>
Information obtained

Array of bounce messages. Each message is represented as an array that includes:

  • date - email reception date
  • email - recipient email address
  • message - content of hard bounced email

Examples

mgapi_campaignBounceMessages.php
campaignBounceMessages($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignBounceMessages()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Messages returned: " . sizeof($retval) . "\n";
    foreach ($retval as $msg) {
        echo $msg['date'] . " - " . $msg['email'] . "\n";
        echo substr($msg['message'], 0, 150) . "\n\n";
    }
}
xml-rpc_campaignBounceMessages.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId),
                    'start' => new xmlrpcval(0),
                    'limit' => new xmlrpcval(25)
                ),
                'struct');
$f = new xmlrpcmsg('campaignBounceMessages', 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 "Messages returned: " . sizeof($retval) . "\n";
    foreach ($retval as $msg) {
        echo $msg['date'] . " - " . $msg['email'] . "\n";
        echo substr($msg['message'], 0, 150) . "\n\n";
    }
} else {
    echo "Unable to run campaignBounceMessages()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignBounceMessages.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
start = 0
limit = 25
 
retval = api.campaignBounceMessages(cid, start, limit)
if api.errorCode:
    print "Unable to load campaignBounceMessages()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Messages returned: %d" % (len(retval))
    for msg in retval:
        print "%s - %s" % (msg['date'], msg['email'])
        print msg['message'][0:150]

© 2010-2017 Mailigen. All rights reserved.