Back to Documentation Overview

campaignAnalytics

public static 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.

Section:
Campaign Stats
Parameters:
apikey a valid API Key for your user account. Get by calling login()
cid the campaign id to pull bounces for (can be gathered using campaigns())
Returns:
array   -  analytics we've collected for the passed campaign.
Returned Fields:
integer visits number of visits
integer pages number of page views
integer new_visits new visits recorded
integer bounces vistors who "bounced" from your site
double time_on_site
integer goal_conversions number of goals converted
double goal_value value of conversion in dollars
double revenue revenue generated by campaign
integer transactions number of transactions tracked
integer ecomm_conversions number Ecommerce transactions tracked
array goals an array containing goal names and number of conversions

Examples (1)

download example code

[1] mcapi_campaignAnalytics.php

  1. <?php
  2. /**
  3. This Example shows how to retrieve Analytics data collected for a campaign with
  4. some basic error checking.
  5. **/
  6. require_once 'inc/MCAPI.class.php';
  7. require_once 'inc/config.inc.php'; //contains apikey
  8.  
  9. $api = new MCAPI($apikey);
  10.  
  11. $stats = $api->campaignAnalytics($campaignId);
  12.  
  13. if ($api->errorCode){
  14. echo "Unable to run campaignAnalytics()!\n";
  15. echo "\tCode=".$api->errorCode."\n";
  16. echo "\tMsg=".$api->errorMessage."\n";
  17. } else {
  18. echo "Visits: ".$stat['visits']."\n";
  19. echo "Pages: ".$rpt['pages']."\n";
  20. echo "Goals ".$rpt['type']."\n";
  21. if ($stat['goals']){
  22. foreach($stat['goals'] as $goal){
  23. echo "\t".$goal['name']." => ".$goal['conversions']."\n";
  24. }
  25. }
  26. }
  27. ?>
  28.  
Add New Note User Contributed Notes for campaignAnalytics
No notes, yet... Will you be the first??