Use Google Tag Manager ( http://www.google.com/tagmanager/ ) in your Rails application.