Skip to main content


Iteratively supports tracking analytics events from Ruby apps.

In Ruby, the tracking library exposes a type-safe function for every event in your team’s tracking plan. The function’s arguments correspond to the event’s properties and are strongly typed to allow for code completion and compile-time checks.


Generate the SDK

If you have not yet installed the Ampli CLI, install it now.

To generate the Itly SDK, run ampli pull {source} in the top-most folder of your project. By default, the SDK will be generated in ./itly/lib/.


{source} is the name of the source you created in your tracking plan (e.g. ruby).

Install dependencies

To validate your analytics events, the Ruby SDK depends on JSONSchemer (MIT). To install this dependency into your project:

  • Add gem "itly", path: "./itly" to your Gemfile
  • Run bundle install as usual

If you've configured Itly with Segment, the steps above will also install those vendor's SDKs:

Import into your app

To use the library, you'll need to import it first:

require 'itly'



Load the Itly SDK once when your application starts. The load method accepts an options object that lets you configure how the Itly SDK works:

contextAn object with a set of properties to add to every event sent by the Itly SDK.

Only available if there is at least one source template associated with your your team's tracking plan.
disabledSpecifies whether the Itly SDK does any work. When true, all calls to the Itly SDK will be no-ops. Useful in local or development environments.

Optional. Defaults to false.
environmentSpecifies the environment the Itly SDK is running in: either production or development. Environment determines which Access Token is used to load the underlying analytics provider libraries.

The option also determines safe defaults for handling event validation errors. In production, when the SDK detects an invalid event, it will log an error but still let the event through. In development, the SDK will throw an exception to alert you that something is wrong.

Optional. Defaults to development.
destinationsSpecifies any analytics provider-specific configuration. The Itly SDK passes these objects in when loading the underlying analytics provider libraries.

loggerTo log Itly's logs to a custom logger, implement the ItlyLogger protocol and set logger to an instance of your class. The Itly SDK will call into your class with all debug, info, warn, and error-level messages.

Click here to see an example written in Ruby.

Optional. Defaults to standard out.

For example:

# With no context properties or custom destinations

# With context properties (e.g. a string property called version)
Itly.load do |options|
options.context =
version: '1.0'

# With all options
Itly.load do |options|
options.environment = ENV['APP_ENV'] || :development
options.destinations.segment = {
max_queue_size: 1000
options.destinations.custom ='custom', {})
options.logger =,
options.context =
version: '1.0'


To track an event, call the event’s corresponding function. Every event in your tracking plan gets its own function in the Itly SDK.

For example, in the code snippet below, our tracking plan contains an event called Process Started. The event was defined with one required property called user_id and one optional property called available_processors. The user_id property's type is a string. The available_processors property's type an integer.

available_processors: Etc.nprocessors