I'm trying to use Google Analytics and record "Screen Views". I know I can manually set a variable in all my actions and pass it to the erb and Google Analytics code. However, I'm trying to avoid duplicating work if it is already available. For example, in Rails, there is controller.action_name for example, or event controller_name and action_name available in .erb.
I typically add a json-encoded data- attribute in layout.erb with these parts as a convenience. If you use jQuery, jQuery will parse the JSON and it's available (for example) in $('body').data('action') (if you placed it on body).