I am developing an app that allows users to see my own Google Analytics Data using Google API v3. Everything I researched seems to indicate that users need to login into their G
Here is a full Google Analytics reporting example implementation with service account including setup notes. Just wrote it after reading your question, I had the same problem.
setScopes(array(SCOPE));
$client->setAssertionCredentials($auth);
$client->getAuth()->refreshTokenWithAssertion();
$accessToken = $client->getAccessToken();
$client->setClientId(CLIENT_ID);
$service = new Google_Service_Analytics($client);
?>
Google Experiments Dashboard
Your experiments
Experiment Page Started Status
management_profiles->listManagementProfiles("~all", "~all");
foreach ($profiles['items'] as $profile) {
$experiments = $service->management_experiments->listManagementExperiments($profile['accountId'], $profile['webPropertyId'], $profile['id']);
foreach ($experiments['items'] as $experiment) {
echo " ";
if ($experiment['status'] == 'RUNNING')
echo '';
else
echo ' ';
$expHref = "https://www.google.com/analytics/web/?pli=1#siteopt-experiment/siteopt-detail/a{$profile['accountId']}w{$experiment['internalWebPropertyId']}p{$experiment['profileId']}/%3F_r.drilldown%3Danalytics.gwoExperimentId%3A{$experiment['id']}/";
echo " {$experiment['name']}";
echo " {$experiment['variations'][0]['url']}";
echo " ".date('Y-m-d',strtotime($experiment['startTime']));
echo " ";
echo '';
foreach ($experiment['variations'] as $i => $variation) {
echo ''.$variation['name'].'';
}
echo '';
}
}
?>
Code with more documentation at https://gist.github.com/fulldecent/6728257
- 热议问题