Bento on Rails

Bento SDK for Ruby

Track events, update data, record LTV and more in Ruby. Data is stored in your Bento account so you can easily research and investigate what's going on.


Add this line to your application's Gemfile:

gem 'bento-sdk', github: "bentonow/bento-ruby-sdk", branch: "master"


If you have a Rails project create an initializer called bento.rb with the following:

site_id = "YOUR-SITE-ID"
# Make Analytics.track() globally available!
::Analytics = site_id) # to use Analytics.track() globally across your application!

Or, if you fancy, just boot it up via:

analytics = "YOUR-SITE-ID")

Then go wild tracking events!

# track a single event
analytics.track(identity: {email: ""}, event: '$action', details: {action_information: "api_test"})
# update a users custom field
analytics.track(identity: {email: ""}, event: '$update_details', custom_fields: {favourite_meal: "bento box"})
# tag a visitor
analytics.track(identity: {email: ""}, event: '$tag', details: {tag: "customer"})
# track a unique event and add LTV (example below tracks $12.34 USD)
analytics.track(identity: {email: ""}, event: '$payment', details: {value: {amount: 1234, currency: "USD"}, unique: {key: 123456}})
# track a pageview server-side
analytics.track(identity: {email: ""}, event: '$view', page: {url: "api_test", title: ""})

Things to know

  1. Tracking: All events must be identified. Anonymous support coming soon!

  2. Tracking: Most events and indexed inside Bento within a few seconds.

  3. Gem: You can stub out events by adding ENV['STUB'].

  4. If you need support, just let us know!


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.