Open GoogleCodeExporter opened 8 years ago
The sample code method you are referring to simply retrieves the first view Id
from that is return from the profiles.list() method.
Can you be more specific with what view (profile) you expected it to return?
Original comment by mcoh...@google.com
on 13 Oct 2015 at 1:31
Whatever this code is does not return the correct id needed to get data back
from GET calls.
function getFirstprofileId(&$analytics) {
// Get the user's first view (profile) ID.
// Get the list of accounts for the authorized user.
$accounts = $analytics->management_accounts->listManagementAccounts();
if (count($accounts->getItems()) > 0) {
$items = $accounts->getItems();
$firstAccountId = $items[0]->getId();
// Get the list of properties for the authorized user.
$properties = $analytics->management_webproperties
->listManagementWebproperties($firstAccountId);
if (count($properties->getItems()) > 0) {
$items = $properties->getItems();
$firstPropertyId = $items[0]->getId();
// Get the list of views (profiles) for the authorized user.
$profiles = $analytics->management_profiles
->listManagementProfiles($firstAccountId, $firstPropertyId);
if (count($profiles->getItems()) > 0) {
$items = $profiles->getItems();
// Return the first view (profile) ID.
//return $items[0]->getId();
$profileId = 103243639;
return $profileId;
} else {
throw new Exception('No views (profiles) found for this user.');
}
} else {
throw new Exception('No properties found for this user.');
}
} else {
throw new Exception('No accounts found for this user.');
}
}
You can see I just found out the id I needed and hard coded it in there. My
account id is 53958006. This code returns some 9000 #. But I finally found
that what you need is the VIEW ID which is a totally different # and then I was
able to get the data I needed.
I don’t know what the profileId is but using it did not provide access to any
of my data or custom variables that I needed to use the API. At least clearly
explain what this is or put a few more examples if this example has nothing to
do with actually pulling real data back from your reporting repository.
Original comment by gweis...@gmail.com
on 13 Oct 2015 at 1:37
https://ga-dev-tools.appspot.com/query-explorer/?csw=1
THIS is how I knew the code was wrong. I could see the ga:{#} was completely
different than the one returned by your code.
Original comment by gweis...@gmail.com
on 13 Oct 2015 at 2:16
Original issue reported on code.google.com by
gweis...@gmail.com
on 13 Oct 2015 at 1:16