Reputation: 11
So i have a project where i use 'google/apis/analytics_v3' to make some requests and get some data, the thing is that i need a view_id to do that.
@service.get_ga_data(VIEW_ID, @start_date, @end_date, 'ga:users').totals_for_all_results
the thing is that, on the new version of the analytics we don't have the view_id and i cannot find a way in ruby to do the same that this does.
Someone knows how to migrate to GA4 in ruby on rails, i can't find much documentation. We are talking about server side requests to google.
Thanks in advance to someone who can help me
I went over the GA4 configs trying to find the view_id, i've seen that this will be deprecated. I've tried find other gems to make the requests and the authentication Went to the github of the gem to check for updates.
Couldn't find a way
Upvotes: 1
Views: 549
Reputation: 117244
The 'google/apis/analytics_v3' library is for use with Universal analytics and requires a view id.
You need to use the Google analytics data api to access google analytics ga4 accounts.
require "google/analytics/data"
Google::Analytics::Data.configure do |config|
config.credentials = "path/to/keyfile.json"
end
client = Google::Analytics::Data.analytics_data
Upvotes: 0