googleapis / google-api-ruby-client

REST client for Google APIs
Apache License 2.0
2.8k stars 868 forks source link

Google reporting only region metrics(location-based), but not demographic metrics(age & gender) for some blogs #6597

Closed inmar-mohan closed 1 year ago

inmar-mohan commented 3 years ago

Hi Team,

Thanks for this awesome gem. We have been using the google-api-client gem to retrieve page view metrics of the blog posts that our users submit to us. As part of collecting page view 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.

We are using google OAuth2 to getaccess_token and refresh_token from our users and using the analytics v3 version to pull the pageviews metrics. Below are the permissions we are requesting in OAuth, please find the attachment:

Screen Shot 2021-10-01 at 5 50 37 PM

Could someone please look into the issue? Any help or suggestions would be much appreciated.

Thanks

inmar-mohan commented 3 years ago

Hi @danoscarmike, thanks for looking into this issue. Any suggestions/advice on this issue, please? We have been facing this issue with most of our users and we are unable to figure out the issue. Any help would be much appreciated. Thanks.

danoscarmike commented 3 years ago

@dazuma could you help me triage/direct this one?

yaditya298 commented 2 years ago

Hi there, we are facing the same issue. Any help here would be much appreciated.

inmar-mohan commented 2 years ago

Hi @danoscarmike, any updates on this issue? Thanks.

danoscarmike commented 2 years ago

@ikuleshov is this something you can help with?

dazuma commented 2 years ago

@inmar-mohan First of all the google-api-client gem is deprecated and hasn't been updated in about a year, so it's possible you're just using an old client. Please use the google-apis-analytics_v3 gem instead. It has the latest updates to the client, and it's specific to analytics v3 (e.g. it doesn't have 70 megabytes of extra ruby code targeting other services).

If the latest version of the google-apis-analytics_v3 gem is still not giving you the information you expect, please find support resources on this page: https://developers.google.com/analytics/devguides/reporting/core/v3/help

bajajneha27 commented 1 year ago

Closing this issue due to inactivity. Please feel free to re-open or reach out to us in case the issue still exists.