Skip to content
Advertisement

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

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')

Advertisement

Answer

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']);
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement