Interesting question. Here’s what I came up with using the above gapi link.
1) Create a snippet something like this one. I’ve left in commented-out code so this is rough. The idea is to generate a TV with radio buttons, allowing you to select whether total pageviews or visits are displayed. It assumes that the gapi code has been put in assets/snippets/gapi.
<?php
require 'actual/filepath/to/assets/snippets/gapi/gapi.class.php';
$output = '';
define('ga_email','your ga email addy');
define('ga_password','your ga email password');
define('ga_profile_id','your ga profile id');
$ga = new gapi(ga_email,ga_password);
if ($ga)
{
$ga->requestAccountData();
/*
foreach($ga->getResults() as $result)
{
$output .= $result . ' (' . $result->getProfileId() . ")<br />";
}
*/
$ga->requestReportData(ga_profile_id,array('browser','browserVersion'),array('pageviews','visits'));
/*
foreach($ga->getResults() as $result)
{
$output .= '<strong>'.$result.'</strong><br />';
$output .= 'Pageviews: ' . $result->getPageviews() . ' ';
$output .= 'Visits: ' . $result->getVisits() . '<br />';
}
$output .= '<p>Total pageviews: ' . $ga->getPageviews() . ' total visits: ' . $ga->getVisits() . '</p>';
*/
$output .= 'Total pageviews==' . $ga->getPageviews() . '||Total visits==' . $ga->getVisits();
}
else
{
$output = 'NA==0';
}
return $output;
?>
2) Create a TV and assign it to the appropriate template:
Type : Radio Options
Default input value : @EVAL return $modx->runSnippet(’the_above_snippet_name’);
3) In a page using that template, select your option and in the resource’s content put something like
My total page views are [*this_template_variable_name*]
This was just quick and dirty. I haven’t played around with what other data is made available.
Hope this helps,
Matt
EDIT : This was tested in Evo 1.0.5. I tried running it in Revo 2.0.7 but it seemed to get hung up and I don’t know why. FWIW ...