Link | google_analytics |
Author | Jason Huck |
Category | Utility |
Version | 8.5.x |
License | Public Domain |
Posted | 02 Aug 2007 |
Updated | 07 Aug 2007 |
More by this author... |
This custom type retrieves reports from Google Analytics. A wide variety of reports can be retrieved in a number of formats, including XML, PDF, and CSV.
->getreport - Retrieves the requested report.
-name - string, required, the report to retrieve. At the time of this writing, the available report names were:
DashboardReport
VisitorsOverviewReport
GeoMapReport
VisitorTypesReport
LanguagesReport
VisitsReport
UniqueVisitorsReport
PageviewsReport
AveragePageviewsReport
TimeOnSiteReport
BounceRateReport
LoyaltyReport
RecencyReport
LengthOfVisitReport
DepthOfVisitReport
BrowsersReport
PlatformsReport
OsBrowsersReport
ColorsReport
ResolutionsReport
FlashReport
JavaReport
NetworksReport
HostnamesReport
SpeedsReport
TrafficSourcesReport
DirectSourcesReport
ReferringSourcesReport
SearchEnginesReport
AllSourcesReport
KeywordsReport
AdwordsReport
KeywordPositionReport
CampaignsReport
AdVersionsReport
ContentReport
TopContentReport
ContentByTitleReport
ContentDrilldownReport
EntrancesReport
ExitsReport
-from - date, required, the start date for period of time to report against.
-to - date, required, the end date for the period of time to report against.
-format - integer from 0 to 3, optional. Defaults to 1. Values are:
0 - PDF
1 - XML
2 - CSV
3 - TSV
-rows - integer, optional. Number of rows to return. Defaults to 10.
// Retrieve and display the XML version of // the Keywords Report for the last month. // Set the content type to XML content_type('text/xml'); // Initialize the custom type and log in // to your Google account. var('ga') = google_analytics( -email='xxxxxxxxx', -password='xxxxxxxxx', -account=xxxxxxxxx ); // Retrieve the desired report. $ga->getreport( 'KeywordsReport', -from=date->subtract( -month=1)&, -to=date );
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_type( 'google_analytics', -description='Retrieves reports from Google Analytics.' ); local( 'account' = string, 'cookies' = string ); define_tag( 'oncreate', -req='email', -req='password', -req='account' ); self->account = #account; local('pp') = array( 'continue' = 'http://www.google.com/analytics/home/?et=reset&hl=en-US', 'service' = 'analytics', 'nui' = '1', 'hl' = 'en-US', 'GA3T' = 'X67XP8PK9ek', 'Email' = #email, 'Passwd' = #password, 'PersistentCookie' = 'yes', 'rmShown' = '1', 'null' = 'Sign in' ); protect; local('login') = include_url( 'https://www.google.com/accounts/ServiceLoginBoxAuth', -postparams=#pp, -retrievemimeheaders='hdr', -timeout=15 ); /protect; local('cookies') = string; iterate($hdr->find('Set-Cookie'), local('i')); #cookies += #i->value + ';'; /iterate; #cookies->removetrailing(';'); self->cookies = #cookies; /define_tag; define_tag( 'getreport', -req='name', -req='from', -type='date', -req='to', -type='date', -opt='format', -type='integer', -opt='rows', -type='integer', -encodenone ); local('gp') = array( 'fmt' = (local_defined('format') ? #format | 1), 'id' = self->account, 'pdr' = (#from->format('%Y%m%d') + '-' + #to->format('%Y%m%d')), 'cmp' = 'average', 'trows' = (local_defined('rows') ? #rows | 10), 'rpt' = #name ); protect; local('data') = include_url( 'https://www.google.com/analytics/reporting/export', -getparams=#gp, -sendmimeheaders=array('Cookie'=self->cookies), -timeout=15 ); /protect; return(#data); /define_tag; /define_type;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
"We're sorry..."
\n\n