chexton
chexton

Reputation: 151

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. 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.

Upvotes: 15

Views: 899

Answers (1)

Kevin
Kevin

Reputation: 4287

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) 

Upvotes: 1

Related Questions