I was wondering what is an effective way to gather analytics data in Rails with Google Analytics.
I’ve used Garb before, and it works fantastically, however it does hang up my app as it fetches the data from google. I’m wanting to make the request snappier.
Is it better to get the data via an ajax request, or do a cron job and save the data directly in my app? Sorry if this sounds daft, I’m looking for some pointers.
Any advice would be great, thanks.
EDIT: I’m using subdomains for different user accounts, and it seems google analytics limits the amount you can track. Does anyone have experience with other platforms for an app?
You can continue to use ‘Garb’, but put the task to background in a scheduled manner. Try Resque, rescue-scheduler: https://github.com/bvandenbos/resque-scheduler
You got to use the :start, :end, :limit, :offset parameters of ‘Garb’ and build your polling logic. Save the data in your local DB if you have extensive calls to the Analytics in your app.