campaignGeoOpens()

Data is obtained about countries in which emails were opened.List (array) of countries and number of opened emails in each country is returned.

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

Array of countries. Each country is represented as an array consisting of:

  • code - country code in ISO3166 format (2 symbols)
  • name - name of country
  • opens - number of opened emails

Examples

mgapi_campaignGeoOpens.php
campaignGeoOpens($cid);
 
header("Content-Type: text/plain");
if ($api->errorCode) {
    echo "Unable to load campaignGeoOpens()!";
    echo "\tCode=" . $api->errorCode . "\n";
    echo "\tMsg=" . $api->errorMessage . "\n";
} else {
    echo "Open from " . sizeof($retval) . " countries:\n";
    foreach ($retval as $country) {
        echo "\t" . $country['code'] . "\t" . $country['name'] . "\t" . $country['opens'] . "\n";
    }
}
xml-rpc_campaignGeoOpens.php
 new xmlrpcval($apikey),
                    'cid' => new xmlrpcval($campaignId)
                ),
                'struct');
$f = new xmlrpcmsg('campaignGeoOpens', 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());
    echo "Open from " . sizeof($retval) . " countries:\n";
    foreach ($retval as $country) {
        echo "\t" . $country['code'] . "\t" . $country['name'] . "\t" . $country['opens'] . "\n";
    }
} else {
    echo "Unable to run campaignGeoOpens()!\n";
    echo "\tCode=" . $r->faultCode() . "\n";
    echo "\tMsg=" . $r->faultString() . "\n";
}
mgapi_campaignGeoOpens.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.campaignGeoOpens(cid)
if api.errorCode:
    print "Unable to load campaignGeoOpens()!"
    print "\tCode=", api.errorCode
    print "\tMsg=", api.errorMessage
else:
    print "Open from %d countries:" % (len(retval))
    for country in retval:
        print "\t", country['code'], "\t", country['name'], "\t", country['opens']

© 2010-2017 Mailigen. All rights reserved.