Documentation

Use your PHP code to work with your media's analytics data. This is possible by using the analytics API methods provided bellow.

Fork me on GitHub
  • get
    Get analytics for the given params
    $ziggeo->analytics()->get($arguments = array())
    
    1. from A UNIX timestamp in microseconds used as the start date of the query
    2. to A UNIX timestamp in microseconds used as the end date of the query
    3. date A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.
    4. query The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how to get analytics data for your application
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. filter_query
    	4. filter_from
    	5. filter_to
    	6. filter_date
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "filter_query:", "filter_from:", "filter_to:", "filter_date::"));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $arguments = array(
    	"query" => $opts["filter_query"] // can be any of: device_views_by_os, device_views_by_date,
    	                                 //   total_plays_by_country, full_plays_by_country, total_plays_by_hour,
    	                                 //   full_plays_by_hour, total_plays_by_browser, full_plays_by_browser
    );
    
    if(isset($opts["filter_from"])) {
    	$arguments['from'] = $opts["filter_from"];
    }
    if(isset($opts["filter_to"])) {
    	$arguments['to'] = $opts["filter_to"];
    }
    if(isset($opts["filter_date"])) {
    	$arguments['date'] = $opts["filter_date"];
    }
    
    $analytics = $ziggeo->analytics()->get($arguments);
    
    var_dump($analytics);
    
    ?>