kotmyrevich / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

Your documentation example doesnt work #753

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
---------------------------------------------------------------------------
NOTE: This tool is not designed to request help. It is only for reporting
issues and requesting features for the Google Analytics libraries.

If you are a developer and you need help, visit:
https://developers.google.com/analytics/help/

If you are not a developer and you need help, visit:
https://support.google.com/analytics
---------------------------------------------------------------------------

Issue summary:
https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/s
ervice-php

This test code doesnt even work.  I have to go to like 100 different websites 
to find out your Firstprofileid method doesnt get the correct id.  So all my 
get queries didnt work.  Now I go the right code and manually set it and the 
queries work.

Fix your documentation Google.

Notes:
Provide any additional information which might be useful here. Feel free to
attach screenshots or sample code which demonstrates the issue being
described.

Original issue reported on code.google.com by gweis...@gmail.com on 13 Oct 2015 at 1:16

GoogleCodeExporter commented 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

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
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