'Google Analytics v3 reporting only region metrics(location-based), but not demographic metrics(age & gender)
We have been using the google-api-client gem to retrieve pageview metrics of the blog posts that our users submit to us. As part of collecting pageview metrics, we collect blog post's dimension metrics(location-based) and demographic metrics(age & gender).
When requesting the dimension region metrics with the blog's view_id, access_token, refresh_token, start_date, and end_date, google is successfully providing the dimension(location-based) metrics.
@query=#<Google::Apis::AnalyticsV3::GaData::Query:0x00005631fe824c78
@dimensions="ga:region,ga:channelGrouping,ga:deviceCategory,ga:sourceMedium",
@end_date="2021-09-30",
@filters="ga:pagePath==/shakshuka-with-feta-poached-eggs-in-tomato-sauce/",
@ids="ga:123297238", @max_results=10000,
@metrics=["ga:pageViews"], @sampling_level="HIGHER_PRECISION",
@start_date="2005-01-01", @start_index=1>, @sample_size=498652, @sample_space=913243, @self_link="https://www.googleapis.com/analytics/v3/data/ga?ids=ga:123297238&dimensions=ga:region,ga:channelGrouping,ga:deviceCategory,ga:sourceMedium&metrics=ga:pageViews&filters=ga:pagePath%3D%3D/shakshuka-with-feta-poached-eggs-in-tomato-sauce/&start-date=2005-01-01&end-date=2021-09-30&max-results=10000",
@total_results=53, @totals_for_all_results={"ga:pageViews"=>"45"}, @rows=[ ["Arizona", "Direct", "mobile", "(direct) / (none)", "2", "2"], ["Arizona", "Organic Search", "desktop", "google / organic", "2", "2"], ["Arizona", "Social", "tablet", "m.facebook.com / referral", "2", "2"], ["Arkansas", "Direct", "mobile", "(direct) / (none)", "2", "2"], ["Arkansas", "Referral", "desktop", "foodgawker.com / referral", "2", "2"], ["California", "Direct", "desktop", "(direct) / (none)", "7", "7"], ["Delaware", "Social", "mobile", "l.facebook.com / referral", "2", "2"], ["Florida", "Direct", "desktop", "(direct) / (none)", "4", "4"], ["Florida", "Organic Search", "tablet", "google / organic", "2", "2"], ["Florida", "Social", "mobile", "m.facebook.com / referral", "2", "2"]...
However, when requesting the demographics data(age & gender) with the same blog's view_id, access_token, refresh_token, start_date, and end_date, google is providing the empty metrics. It's returning @total_results=0.
@query=#<Google::Apis::AnalyticsV3::GaData::Query:0x00005631fe754a00
@dimensions="ga:userGender,ga:userAgeBracket", @end_date="2021-09-30",
@filters="ga:pagePath==/shakshuka-with-feta-poached-eggs-in-tomato-sauce/",
@ids="ga:123297238", @max_results=10000, @metrics=["ga:pageViews"], @sampling_level="HIGHER_PRECISION",
@start_date="2005-01-01", @start_index=1>, @sample_size=498652, @sample_space=913243,
@self_link="https://www.googleapis.com/analytics/v3/data/ga? ids=ga:123297238&dimensions=ga:userGender,ga:userAgeBracket&metrics=ga:pageViews&filters=ga:pagePath%3D%3D/shakshuka-with-feta-poached-eggs-in-tomato-sauce/&start-date=2005-01-01&end-date=2021-09-30&max-results=10000",
@total_results=0, @totals_for_all_results={"ga:pageViews"=>"0"}>
For some blog posts, Google is reporting both demographics and region-wise data without any issues. But we are seeing this issue with the most number of blogs in our system and we are unable to figure out why google is returning only region metrics, but no results for demographics.
Tried to get demographics data, but I am getting only region-wise data. I am expecting demographic(age & gender) data as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
