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
my code
JavaScript
x
$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
JavaScript
//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']);