Librería PHP para Google Analytics

Librería PHP que nos permite obtener los datos de Google Analytics tipo Visitas y Páginas Vistas de forma muy sencilla y cómoda:

//session_start for caching, if desired
session_start();
//get the class
require 'ga/analytics.class.php';
//sign in and grab profile
$analytics = new analytics('david@davidwalsh.name', 'myP@ssw0rd');
$analytics->setProfileByName('davidwalsh.name');
//set the date range for which I want stats for (could also be $analytics->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD'))
$analytics->setMonth(date('n'), date('Y'));
//get array of visitors by day
print_r($analytics->getVisitors());
//get array of pageviews by day
print_r($analytics->getPageviews());

Google Analytics PHP API class

Vía / David Walsh Blog

Similar Posts