Home
Quick start
Identifying users
Tracking events
Tracking groups

Technical Guides

Browser
Node.js
Ruby
Python
HTTP API
License
Sign in

Ruby API

Instant insights from any Ruby app

Installing

To install the gem from Ruby Gems into a ruby app, simply run:

1
gem install june-analytics-ruby

Configuring

Now, you must configure the June SDK with a valid API key, which you can get from your June workspace.

1
require 'june/analytics'
2
3
Analytics = June::Analytics.new({
4
write_key: 'YOUR_WRITE_KEY'
5
})

Identifying users

You can use the identify method to identify your users.

1
Analytics.identify(user_id: 42,
2
traits: {
3
email: 'name@example.com',
4
first_name: 'Foo',
5
last_name: 'Bar'
6
})

Identifying companies (optional)

You can use the group method to identify your companies.

1
Analytics.group(user_id: 42,
2
group_id: 53,
3
traits: {
4
email: 'name@example.com',
5
first_name: 'Foo',
6
last_name: 'Bar'
7
})

Send track events

In order to track user behaviour, you can use the track method.

Note: If you're identifying companies, you should pass the groupId in the track context, as shown in the example below.

1
Analytics.track(user_id: 42,
2
event: 'Created Account',
3
context: {
4
group_id: 12
5
})

Our SDK is based on Segment's SDK. You can find more documentation here: https://segment.com/docs/connections/sources/catalog/libraries/server/ruby