How to return page views for each day of the past week?

Davis Zhao :

ga:pageviews

How to return page views for each day of the past week?

I can only get the total page views for a certain period of time

The following figure is the analysis result I expected

enter image description here

enter image description here

my code

$pageViews = $analyticsService->getPageViewsDateRange($viewId,'30daysAgo','today')
Davis Zhao :

Thank you DaImTo The following code can get the analysis results I want, I hope it can help others

I useGoogle Analytics API Symfony Bundle

        //Get daily views for the past week
        $pageView = $analyticsService->getDataDateRangeMetricsDimensions($viewId, '7daysAgo', 'today', ['pageviews'], ['date']);

        //Get page views every hour of the day
        $pageView = $analyticsService->getDataDateRangeMetricsDimensions($viewId, 'today', 'today', ['pageviews'], ['hour']);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=220153&siteId=1