« Back to Documentation OverviewcampaignClickStats – v1.3
campaignClickStats(string apikey, string cid)
Get an array of the urls being tracked, and their click counts for a given campaign
| Parameters | | apikey | a valid API Key for your user account. Get by visiting your API dashboard |
| cid | the campaign id to pull stats for (can be gathered using campaigns()) |
| Returns | | array |
urls will be keys and contain their associated statistics:
| int | clicks | Number of times the specific link was clicked
| | int | unique | Number of unique people who clicked on the specific link
| |
Examples (2)
download example code
[1] mcapi_campaignClickStats.php
<?php
/**
This Example shows how to pull and iterate through a campaignClickStats call via
using the MCAPI wrapper class.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$stats = $api->campaignClickStats($campaignId);
if ($api->errorCode){
echo "Code=".$api->errorCode."\n\t"; echo "Msg=".$api->errorMessage."\n"; } else {
echo "No stats for this campaign yet!\n"; } else {
foreach($stats as $url=>$detail){
echo "\tClicks = ".$detail['clicks']."\n"; echo "\tUnique Clicks = ".$detail['unique']."\n"; }
}
}
?>
[2] xml-rpc_campaignClickStats.php
<?php
/**
This Example shows how to iterate through a campaignClickStats call using XML-RPC.
Note that we are using the PEAR XML-RPC client and recommend others do as well.
**/
require_once 'XML/RPC2/Client.php';
require_once 'inc/config.inc.php';
try {
$result = $client->campaignClickStats($apikey, $campaignId);
foreach($result as $url=>$stats){
echo "Clicks = ".$stats['clicks']." Unique Clicks = ".$stats['unique']."\n"; }
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }
?>