14

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.

Cœur
  • 32,421
  • 21
  • 173
  • 232
user1915482
  • 141
  • 1
  • 3
  • Since you suspect the cookies aren't correct... Can you also show some calling code? Specifically the cookiea and cookiez should be from cookies[:__utma] and cookies[:__utmz] from your controller. – Colin Curtin Sep 19 '13 at 22:44

1 Answers1

1

Looks like the analytics.js code changed recently and perhaps it's caused an issue with gabba:

https://github.com/hybridgroup/gabba/issues/25

I use gabba for custom events to keep track of # of new user signups, and it seems to be working ok though may be overinflating my #hits count per the issue above.

gabba = Gabba::Gabba.new("UA-blah", "mysite.com")
gabba.identify_user(cookies[:__utma])
gabba.event(kind, action, title, 0, true) 
Kevin
  • 4,039
  • 2
  • 32
  • 40