Search code examples
phpapigoogle-analyticsgoogle-analytics-api

Google Analytics Not listing all web properties


When using google analytics core reporting api i am unable to get all properties of an account some properties are missing and all are those which has no view in analytics dashboard of google here is my code

$data=[];$id = "abc1234";
    $properties = $this->analytics->management_webproperties
        ->listManagementWebproperties("~all")->getItems();
    foreach ($properties as $user) {
        $data[$user->getId()] = ['id' => $user->getId(), 'name' => $user->getName()];
    }
    return collect(array_values($data));

please tell me if i miss something or not using latest version of api i am using V4. please help me. Thanks


Solution

  • The APIs you are using are for the Google Analytics Universal version, while the properties that 'don't have a view' are from Google Analytics 4 (the new Google Analytics, ex App+Web).

    This version of Google Analytics offers its API specifications (Analytics Data API), you can see here an early preview version: https://developers.google.com/analytics/devguides/reporting/data/v1