Skip to main content

Ruby Server SDK

This SDK is written in Ruby, and is open source and hosted on github.

The Basics#

Get started in a few quick steps.

  1. Create a free account on
  2. Install the SDK
  3. Initialize and use the SDK

Step 1 - Create a free account on

You could skip this for now, but you will need an SDK Key and some Feature Gates or Dynamic Configs to use with the SDK in just a minute.

Step 2 - Install the SDK#

If you are using Bundler, add the gem to your Gemfile from command line:

bundle add statsig --version ">= 1.0.0"

or directly include it in your Gemfile and run bundle install:

gem "statsig", ">= 1.0.0"

Step 3 - Initialize and use the SDK#

Initialize the SDK using a Server Secret Key from the statsig console:

require 'statsig'
# Now you can check gates, get configs, log events for your users.
# e.g. if you are running a promotion that offers all users with a email a discounted price on your monthly subscription service,
# 1. you can first use check_gate to see if they are eligible
user ={'email' => ''})
if Statsig.check_gate(user, 'has_statsig_email')
# 2. then get the discounted price from dynamic config
price_config = Statsig.get_config(user, 'special_item_prices')
@sub_price = price_config.get('monthly_sub_price')
# 3. log the conversion event - 'purchase_made' - once they make the purchase
Statsig.log_event(user, 'purchase_made', 1, {'price' => @sub_price})