Joined March 2013
·

Richard Ortega

Developer at TrueAbility
·
San Antonio, Texas
·
·
·

Nice post and very helpful, have some code they may help others:

1) I think you meant to use strip instead of stripe in the track_event method.

2) Also, for people unfamiliar with HAML here is the equivalent code in ERB:

<%= javascript_tag do %>
 <%= analytics_events.html_safe %>
<% end %>

3) Here's a little refactor that may help in clarity:

track_event in application_controller.rb

def track_event(event, options = nil)
    json_args = "#{event.to_json},#{options.to_json}"
    flash[:events] ||= []
    flash[:events] << json_args
  end

and
How to call track_event within a controller

track_event('Signed Up', {user_id: @user.id, 
                        category: 'foobar'})
Achievements
60 Karma
0 Total ProTip Views