Install our Ruby Gem in order to send events and traits to from your server using Ruby.

Add this line to your application’s Gemfile:

gem 'replay_api'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install replay_api

See GitHub for more detailed information on configuring the library and its usage.


First, configure the library with your replay_key. In Rails this is best done in an initializer. Outside of Rails, it just needs to happen before you start sending events and traits.

ReplayApi.configure do |config|
  config.replay_key = 'xxx-xxx-xxx-xxx'

You may opt to create a globally accessible instance of the client or you can create a new one for each event. In either case, the mechanism for sending events and traits is the same.

Send an Event

client =
client.event do |event|
  event.event_name = 'Purchase'
  event.distinct_id = = 100

Send a Trait

client =
client.trait do |trait|
  trait.distinct_id = =