List of all the links found in campaign is obtained, as well as the number of total clicks and unique clicks.
campaignClickStats(string $cid) : struct
Array of links consisting of:
<?php /** * This Example shows how to campaignClickStats using the MGAPI.php class and do some basic error checking. */ require_once 'inc/MGAPI.class.php'; require_once 'inc/config.inc.php'; //contains apikey $api = new MGAPI($apikey); $cid = $campaignId; $retval = $api->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 "Link id: {$detail['id']} - {$detail['url']}\n"; echo "\tClicks = {$detail['clicks']}\n"; echo "\tUnique Clicks = {$detail['unique']}\n"; } } }
<?php /** * This Example shows how execute a campaignClickStats and check the result using XML-RPC. * Note that we are using the PEAR XML-RPC client and recommend others do as well. */ require_once 'xmlrpc-3.0.0.beta/xmlrpc.inc'; require_once 'inc/config.inc.php'; $apiUrl = parse_url($apiUrl); $v = new xmlrpcval(array( 'apikey' => 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"; }
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'])