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 = Bento::Analytics.new(write_key: site_id) # to use Analytics.track() globally across your application!
Or, if you fancy, just boot it up via:
analytics = Bento::Analytics.new(write_key: "YOUR-SITE-ID")
Then go wild tracking events!
# track a single eventanalytics.track(identity: {email: "user@yourapp.com"}, event: '$action', details: {action_information: "api_test"})# update a users custom fieldanalytics.track(identity: {email: "user@yourapp.com"}, event: '$update_details', custom_fields: {favourite_meal: "bento box"})# tag a visitoranalytics.track(identity: {email: "user@yourapp.com"}, event: '$tag', details: {tag: "customer"})# track a unique event and add LTV (example below tracks $12.34 USD)analytics.track(identity: {email: "user@yourapp.com"}, event: '$payment', details: {value: {amount: 1234, currency: "USD"}, unique: {key: 123456}})# track a pageview server-sideanalytics.track(identity: {email: "user@yourapp.com"}, event: '$view', page: {url: "api_test", title: ""})
Tracking: All events must be identified. Anonymous support coming soon!
Tracking: Most events and indexed inside Bento within a few seconds.
Gem: You can stub out events by adding ENV['STUB'].
If you need support, just let us know!
Bug reports and pull requests are welcome on GitHub at https://github.com/bentonow/bento-ruby-sdk. 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.