klenwell information services : GreqoAnalytics

Greqo Analytics


note: This class has been successfully tested. However, it has not been extensively tested. If you encounter any bugs, please either report them here or contact me

Overview

Google does not provide a Google Data API for their Analytics service. Using the Greqo client, however, it is possible to programmatically query your Analytics account. I started developing it originally in order to enable email delivery of Analytics reports. Analytics now offers this feature itself, however they do not offer the ability to email simple daily or periodic reports in-text. Greqo Analytics gives you the ability to do that.

Click here for a comparison of a Google Analytics email report and a Greqo Analytics email report

This library follows in the footstep of similar PHP packages: the tantan wordpress plug-in and the Cake PHP framework extension. Both of these packages were created for particular frameworks. Greqo Analytics tries to offer a more stand-alone tool. It is also includes a caching feature and is compatible with the updated version of Google Analytics.

caveat
Because this is not an official Google API and uses simulated browser behavior as a workaround, this package is dependent on the Greqo Analytics web interface and therefore somewhat fragile. Any changes in the Greqo Analytics interface could easily break it. It is offered simply as a convenience for obtaining regular daily email reports and should be used advisedly.

Usage

require_once('../analytics.class.php');
$GreqoAnalytics = new GreqoAnalytics($debug=1);
$GreqoAnalytics->email = 'user@gmail.com';
$GreqoAnalytics->password = 'password';
$GreqoAnalytics->site_id = '0000001';       /* if not sure, login and right click link on overview -- it should be embedded there */

// get report
$start_uts = time() - $GreqoAnalytics->day_sec;
$stop_uts = $start_uts;
$summary = $GreqoAnalytics->get_site_summary($start_uts, $stop_uts);
echo "<pre>$summary</pre>";


Sample Output

$summary output from above
Greqo Analytics Summary for Phosphorus and Lime (blog)

DATES: June 16, 2007 - June 16, 2007 
VISITORS: 13 (Previous: 28 / -53.57%)
PAGE VIEWS: 13 (Previous: 33 / -60.61%)
UNIQUE VISITORS: 13 (Previous: 27 / -51.85%)

SOURCES
source/medium : visits | pg/v | time (s) 
1. google / organic : 13 | 1.0 | 0 


KEYWORDS
keywords : visits 
1. myspace table font color css : 1
2. myspace masthead : 1
3. unable to sign on to blogger : 1
4. myspace/samy : 1
5. myspace stylesheet : 1
6. nifty cube body transparent : 1
7. tiny myspace profile style sheet : 1
8. class 'html_template_flexy' not found in : 1
9. myspace wrapper table width : 1
10. phpmailer gmail : 1


CONTENT
page (url) : views | unique | time (s) 
1. /2005/10/css-latest-myspace-profile-stylesheet.html : 4 | 4 | 0 
2. /2006/08/css-myspace-civilized.html : 3 | 3 | 0 
3. /2005/12/php-mvc-demo.html : 1 | 1 | 0 
4. /2007/05/phpmailer-with-gmail.html : 1 | 1 | 0 
5. / : 1 | 1 | 0 
6. /2006/01/php-mysql-statements-in-heredocs.html : 1 | 1 | 0 
7. /2005/10/myspace-samy-worm.html : 1 | 1 | 0 
8. /2006_01_01_archive.html : 1 | 1 | 0 


References

Source Code
Analytics Home Page

Similar Packages

TanTan WordPress Plug-In
Cake PHP Analytics Package


CategoryGreqo