sarahsemark/suitor — pull request #161 by sarahsemark (2014-12-18 10:13:31+00:00)
Title: WIP: User tracking

I'm not entirely sure if this works right—mostly because testing in GA is something of a nightmare, but I've already spent way too much time working on this, so I'm leaving it as-is (and deployed to production) for the time being.

Here's what I've done:

GA tracking code has been added to all pages. It's probably not quite working right with turbolinks, but I'm not (offhand) sure how to fix that while making use of the universal code.

Technically it's sending user data to GA, although again, hard to test and hard to see. For logged in users, it sends the user id as a custom dimension first, and then again using the UserID feature built into GA (https://support.google.com/analytics/answer/3123662?hl=en&utm_id=ad), both of which do slightly different things.

I think at this stage, this probably requires accurate tracking of pageviews with turbolinks, as well as useful data extraction.

http://www.topdan.com/ruby-on-rails/finding-your-most-active-users-with-google-analytics.html has some good ideas (there are a few gems that allow you to access the GA API via a Rails app, which could be handy.

https://github.com/tpitale/legato does some neat stuff with GA, but I think it's more functionality than strictly required.

https://coderwall.com/p/xpjhbw/track-server-side-events-from-rails-in-google-analytics
https://megalytic.com/blog/using-google-analytics-events-to-track-engagement

...might be good places to start.

Fixes #156.