For the last 2-3 days i am trying to somehow download the “Pages and screens: Page path and screen class” reports so i can include the data on my management system,
I tried to use the Google Analytics API in PHP, here is an example
$analytics = new Google_Service_Analytics($client); $profileId = ''; // But i cant get the profile id because the Analytics account doesnt have them $yesterday = $startDate = $endDate = date("Y-m-d", time() - 60 * 60 * 24); $metrics = 'sessions'; $results = $analytics->data_ga->get('ga:' . $profileId, $startDate, $endDate, 'ga:' . $metrics); print_r($results);
But as mentioned in the code my Google Analytics account doesn’t have Views
Here again summarized i need a way to download the report seen as in the picture automatically, it could be in any language (ex PHP, Python, Java etc)
Advertisement
Answer
You are using Reporting API that works only for Universal Analytics Property. In your case you are trying to get info from the new Google Analytics 4 Property, not Universal Analytics. So you have to use the Google Analytics Data API: https://developers.google.com/analytics/devguides/reporting/data/v1