I use Google Analytics to track pageviews, etc. but late last week I had the desire to track an event on the backend.
I discovered gabba.
I have a method within my User model that looks like this:
def track_ga(event_name, cookiea, cookiez, event_category=nil)
return unless Rails.env.production?
gabba = Gabba::Gabba.new("UA-MYCODE-1", "mywebsite.com")
gabba.identify_user(cookiea, cookiez)
gabba.set_custom_var(1, 'User Email', self.email, Gabba::Gabba::VISITOR)
gabba.set_custom_var(2, 'Private Code', private_code, Gabba::Gabba::VISITOR) if private_code
gabba.event(event_category || "Users", event_name, nil, nil)
end
However it's not working correctly, here are the results in GA:
To me, that suggests that the cookies are not correctly associated, i.e. it has no idea of where they previously visited (before this event was tracked). Perhaps I am misunderstanding the nature of this report but, assuming I'm not, I'd love some advice on where I'm going wrong.