Using with Rails

This tutorial will walk you through getting set up with on a standard Rails application and getting people to show up in the campaign --SAMPLE-- Welcome campaign behavioral campaign.

Add the gem to your Gemfile

gem 'customerio', :git => ''

Run bundle install to install the gem then we’ll set up the configuration.


We’ll add your Site ID and API Key. We can do this in an initializer to save time and make sure we don’t accidentally commit sensitive data into source control.

# config/initializers/customerio.rb
Rails.configuration.customerio = {
  :site_id      => ENV['CIO_SITE_ID'],
  :api_key      => ENV['CIO_API_KEY']

$customerio =[:site_id], Rails.configuration.customerio[:api_key])

Identify People to

Above we created the variable $customerio in an initializer. We can now use that in our app to pass data to

Let’s identify people when they get created. Add a code snippet like this in your registrations controller:

  id: @id,
  created_at: @created_at,
  email: @email,
  first_name: @first_name,
  last_name: @last_name,

We’re using instance variables like @email defined in the controller.

*Note: created_at is a very important attribute for To see people match the “Welcome” campaign they must have signed up within the past 24 hours.

Create a new user

If you now go back to your application and create a new user, you will see them queued up and ready to send in

Deploying to Heroku

heroku create
heroku config:set CIO_SITE_ID=xxxxxxx CIO_API_KEY=yyyyyyy
git push heroku master
heroku open


Stripe’s amazing guide for Using Stripe’s Checkout and Rails inspired the creation and structure of this guide