Campaign statistics

smsCampaignStats()

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

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

SMS campaign statistics is represented as an array that includes:

  • delivered - number of delivered SMS
  • sent - number of sent SMS. Information about success or failure is not yet received.
  • queued - number of SMS that are queued and still waiting to be sent
  • temporary_bounces - temporary bounces
  • undelivered - number of undelivered SMS
  • error - number of undelivered SMS that were having some technical issues during the process of delivery
  • other - number of SMS having other status of delivery
  • 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
  • sms_sent - total number of sent SMS

Examples

mgapi_smsCampaignStats.php
smsCampaignStats($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignStats()!";
    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";
    }
}

smsCampaignClickStats()

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

smsCampaignClickStats(string $cid) : struct
Input parameters
  • cid - SMS 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_smsCampaignClickStats.php
smsCampaignClickStats($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load smsCampaignClickStats()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    if (sizeof($retval) == 0) {
        echo "No stats for this sms campaign yet!\n";
    } else {
        foreach ($retval as $url => $detail) {
            echo "URL: " . $url . "\n";
            echo "\tClicks = " . $detail['clicks'] . "\n";
            echo "\tUnique Clicks = " . $detail['unique'] . "\n";
        }
    }
}

smsCampaignBounces()

Messages are received from SMS recipient phone carrier in cases SMS was not delivered. Phone list with additional parameters is returned.

smsCampaignBounces(string $cid, integer $start, integer $limit) : array
Input parameters
  • cid - SMS 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 25. Maximum allowable value is 50.
Information obtained

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

  • phone - recipient phone number
  • reason - reason why SMS was not delivered

Examples

mgapi_smsCampaignBounces.php
smsCampaignBounces($cid, $start, $limit);
 
header("Content-Type: text/plain");
if ($api->errorCode){
    echo "Unable to load smsCampaignBounces()!";
    echo "\tCode=".$api->errorCode."\n";
    echo "\tMsg=".$api->errorMessage."\n";
} else {
    echo "SMS not delivered: ". sizeof($retval). "\n";
    foreach($retval as $msg){
        echo $msg['phone']."\n";
        echo $msg['reason']."\n\n";
    }
}

© 2010-2017 Mailigen. All rights reserved.