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'])

© 2010-2017 Mailigen. All rights reserved.