« Back to Documentation OverviewcampaignAnalytics – v1.3
campaignAnalytics(string apikey, string cid)
Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
| Parameters | mcapi_campaignAnalytics.php| apikey | a valid API Key for your user account. Get by visiting your API dashboard |
| cid | the campaign id to pull bounces for (can be gathered using campaigns()) |
| Returns | | array |
analytics we've collected for the passed campaign.
| int | visits | number of visits
| | int | pages | number of page views
| | int | new_visits | new visits recorded
| | int | bounces | vistors who "bounced" from your site
| | double | time_on_site | the total time visitors spent on your sites
| | int | goal_conversions | number of goals converted
| | double | goal_value | value of conversion in dollars
| | double | revenue | revenue generated by campaign
| | int | transactions | number of transactions tracked
| | int | ecomm_conversions | number Ecommerce transactions tracked
| | array | goals | an array containing goal names and number of conversions
| string | name | the name of the goal
| | int | conversions | the number of conversions for the goal
| | |
Examples (1)
download example code
[1] mcapi_campaignAnalytics.php
<?php
/**
This Example shows how to retrieve Analytics data collected for a campaign with
some basic error checking.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$stats = $api->campaignAnalytics($campaignId);
if ($api->errorCode){
echo "\tCode=".$api->errorCode."\n"; echo "\tMsg=".$api->errorMessage."\n"; } else {
echo "Visits: ".$stat['visits']."\n"; echo "Pages: ".$rpt['pages']."\n"; echo "Goals ".$rpt['type']."\n"; if ($stat['goals']){
foreach($stat['goals'] as $goal){
echo "\t".$goal['name']." => ".$goal['conversions']."\n"; }
}
}
?>