Skip to content

Statistics

pilsetnieks edited this page Sep 18, 2012 · 2 revisions

See Making API calls about making requests to the API.

This section of the API lets you retrieve various statistics and aggregate counts about the campaign.

Statistics:General

Get returns general statistics and aggregates from the campaign

Example URL: https://premium.sales.lv/API:1.0/Key:1234567890abcdef/Code:demo/Statistics:General
HTTP method: GET
No parameters required.

Returns an associative array with statistics data:

  • int ID Campaign ID

  • array Totals Total message counts. An associative array with four elements:

    • Before Messages that were submitted before the campaign start time. If the campaign has no start time, no messages should be counted here.
    • After Messages that were submitted after the campaign end time (if it has one).
    • During Messages that are submitted during the campaign.
    • Total Total message counts

    Each of these elements is an associative array with this structure listing each message type (as defined in Messages) and a total value:

    • int SMS Number of messages sent via SMS.
    • int API Number of messages submitted through this API.
    • int OPER Number of messages entered by call center operators.
    • int Total Total message count
  • array Averages Average message counts per day. Contains three elements:

    • Total Average message counts per day during all of campaign time
    • Weekdays Average message counts per day during weekdays (Monday-Friday)
    • Weekends Average message counts per day during weekends (Saturday and Sunday)

    Here, too, each of these elements is an associative array with SMS, API, OPER message counts, as well as Total for average value over all message types.

  • array Genders Gender counts for participants in campaigns they can be determined:

    • int Male
    • int Female

    The number returned is participant (end user) count, not message count. By default messages are recognized to be from the same participant by their phone number, although it is possible to set a different variable if necessary.

PHP example

$API = new PremiumAPI('1234567890abcdef', 'demo');
$GeneralStats = $API -> Statistics_General();
print_r($GeneralStats);

Outputs:

Array
(
    [ID] => 25
    [Totals] => Array
    (
        [Before] => Array
        (
            [SMS] => 1
            [API] => 0
            [OPER] => 0
            [Total] => 1
        )
        [During] => Array
        (
            [SMS] => 27
            [API] => 4
            [OPER] => 0
            [Total] => 31
        )
        [After] => Array
        (
            [SMS] => 0
            [API] => 1
            [OPER] => 0
            [Total] => 1
        )
        [Total] => Array
        (
            [SMS] => 28
            [API] => 5
            [OPER] => 0
            [Total] => 33
        )
    )
    [Averages] => Array
    (
        [Total] => Array
        (
            [SMS] => 0.59
            [API] => 0.09
            [OPER] => 0
            [Total] => 0.67
        )
        [Weekends] => Array
        (
            [SMS] => 0.25
            [API] => 0.08
            [OPER] => 0
            [Total] => 0.33
        )
        [Weekdays] => Array
        (
            [SMS] => 0.71
            [API] => 0.09
            [OPER] => 0
            [Total] => 0.79
        )
    )
    [Genders] => Array
    (
        [Male] => 12
        [Female] => 17
    )
)

Clone this wiki locally