NAME
Net::Google::Analytics - Simple interface to the Google Analytics Data Export API
DESCRIPTION
This module provides a simple, straight-forward interface to the Google Analytics Data Export API, using LWP::UserAgent and XML::LibXML for the heavy lifting.
See http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide.html for the complete API documentation.
SYNOPSIS
use Net::Google::Analytics;
use Net::Google::AuthSub;
my $auth = Net::Google::AuthSub->new(service => 'analytics');
$auth->login($user, $pass);
my $analytics = Net::Google::Analytics->new();
$analytics->auth_params($auth->auth_params);
my $data_feed = $analytics->data_feed;
my $req = $data_feed->new_request();
$req->dimensions('ga:...');
$req->metrics('ga:...');
$req->start_date('YYYY-MM-DD');
$req->end_date('YYYY-MM-DD');
my $res = $data_feed->retrieve($req);
my $entry = $res->entries->[$i];
print $entry->dimensions->[0]->value;
print $entry->metrics->[0]->value;
$analytics->finish();
CONSTRUCTOR
new
my $analytics = Net::Google::Analytics->new();
The constructor doesn't take any arguments.
ACCESSORS
account_feed
The Analytics account feed, an object of type Net::Google::Analytics::AccountFeed.
data_feed
The Analytics data feed, an object of type Net::Google::Analytics::DataFeed.
METHODS
finish
$analytics->finish();
Cleans up circular references between the $analytics object and the feeds. This should be called to make sure the object is destroyed after use.
auth_params
$analytics->auth_params(@auth_params);
Set the authentication parameters as key/value pairs. The values returned from "auth_params" in Net::Google::AuthSub can be used directly.
user_agent
$analytics->user_agent($ua);
Sets the LWP::UserAgent object to use for HTTP(S) requests. You only have to call this method if you want to provide your own user agent, e.g. to change the HTTP user agent header.
AUTHOR
Nick Wellnhofer <wellnhofer@aevum.de>
COPYRIGHT AND LICENSE
Copyright (C) Nick Wellnhofer, 2010
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.