Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gabba gem not tracking correctly

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.

like image 367
user1915482 Avatar asked Dec 19 '12 11:12

user1915482


1 Answers

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) 
like image 177
Kevin Avatar answered Oct 25 '22 16:10

Kevin