Can I get analysis event information using Google Analytics API?
I was able to confirm that I could retrieve page view information using Python and Reporting API v4.
However, I can't get information on the event (details in the attached file).
Or rather, I tried to find out if I could get event information through API, but I don't know.
If anyone knows, please let me know.
Reference Site
Reporting API v4
https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet?hl=ja
Self-Solving!
Resolved by adding "ga:eventAction" to "dimensions" as shown below.
Documentation
https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/?hl=ja
def get_report(analytics, next_page_token="0"):
request_body = {
"reportRequests": [{
"viewId": VIEW_ID,
"pageSize": 100000,
"pageToken": next_page_token,
"dateRanges": [{'startDate':'7daysAgo', 'endDate':'today'}],
"metrics": [{ "expression": "ga:pageviews"}, { "expression": "ga:users"}, { "expression": "ga:avgTimeOnPage"}],
# "metrics": [{ "expression": "ga:users"}]
"dimensions": [{"name":"ga:pagePath"}, {"name":"ga:pageTitle"}, {"name":"ga:eventAction"}],
"orderBys": [{"fieldName": "ga:pageviews", "sortOrder": "DESCENDING"}]
}]
}
return analysis.reports().batchGet(body=request_body).execute()
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
877 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
595 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.