Segment makes it easy to send your data to Keen (and lots of other destinations). Once you've tracked your data through our open source libraries we'll translate and route your data to Keen in the format they understand. Learn more about how to use Keen with Segment.
Getting Started
When you toggle on Keen in Segment, this is what happens:
- Our CDN is updated within 5-10 minutes. Then our snippet will start asynchronously loading keen.js onto your page. This means you should remove Keen’s snippet from your page.
- Since Keen only records custom events and custom user data, no events or users will appear in Keen until you start using the API outlined below.
Keen is supported on the client side and server side.
Identify
Client-Side
When you call identify
on analytics.js
, we call Keen’s setGlobalProperties
and set the user
field with userId
and traits
.
Note: To see this information inside Keen, you must make track
call as the userId
and traits
are simply cached on the client. Your subsequent track
calls will be appended with the userId
and traits
.
Server-Side
On the server-side, calling identify
has no effect on Keen.
Track
Client-Side
When you call track
or one of its helpers functions on analytics.js, we call Keen’s addEvent
with exactly the same parameters.
Server-Side
When you call track
on on the server-side, we route the event to Keen.
If you make the following Segment call using any of the server-side sources,
analytics.track('user@gmail.com', 'Purchased', {
item: 'T-Shirt',
revenue: 19.99
});
We will forward the following to Keen:
- Event Collection:
Purchased
- Event Properties:
{ userId: 'user@gmail.com' item: 'T-Shirt', revenue: 19.99 }
Personas
You can send computed traits and audiences generated through Segment Personas to this destination as a user property. To learn more about Personas, reach out for a demo.
For user-property destinations, an identify call will be sent to the destination for each user being added and removed. The property name will be the snake_cased version of the audience name you provide with a true/false value. For example, when a user first completes an order in the last 30 days, we will send an identify call with the property order_completed_last_30days: true
, and when this user no longer satisfies we will set that value to false
.
When the audience is first created an identify call is sent for every user in the audience. Subsequent syncs will only send updates for those users which were added or removed since the last sync.
Supported Sources and Connection Modes
Web | Mobile | Server | |
---|---|---|---|
📱 Device-based | ✅ | ||
☁️ Cloud-based | ✅ | ✅ | ✅ |
To learn more about about Connection Modes and what dictates which we support, see here.
We offer an optional Cloud-based Connection Mode for Web data with Keen. As a reminder, this removes the Keen javascript library from your site, improving performance. However, there are a few disparities between the Cloud-based and Device-based connection modes to keep in mind brefore enabling it in the Segment app. When you enable the Cloud-based destination mode, here’s what happens:
For data recording use cases, we recommend using the cloud-based connection mode with Keen, as our server-side integration offers robust mapping and parity with all of their data enrichment add ons. Note that if you opt out of a device-based connection with Keen, you cannot use their client side library for charting or querying. User data is augmented to the payload in a different manner via our cloud-based integration versus our device-based one, so we recommend writing to a new, dedicated stream if you elect to use the cloud-based connection mode.
Settings
Segment lets you change these destination settings via your Segment dashboard without having to touch any code.
Track an Initial Pageview
This will send an intial ‘Loaded a Page’ event to Keen when the page is loaded. We disable this by default since Keen is generally used for custom event tracking, not pageviews. Note: you must also have the Send Pageview Events setting enabled for this to work.
Geo IP Addon
Enable this to use Keen’s data enrichment feature to add geographic information based on IP.
Project ID
Your project ID. It should be 24 characters long, and look something like this: 9181bcd23843312d87000000
.
Read Key
If you are a Keen Pro user, enter your read key in the advanced settings tab of your dashboard. It should be a minimum of 32 characters long and made up of numbers and letters only.
Referrer Parsing Addon
Enable this to use the Keen IO’s data enrichment feature for parsing referrer URLs into their source.
Track All Pages to Keen
This will track Loaded a Page events to Keen for all page
method calls.
Track Categorized Pages to Keen
This will track events to Keen for page
method calls that have a category
associated with them. For example page('Docs', 'Index')
would translate to Viewed Docs Page.
Track Named Pages to Keen
This will track events to Keen for page
method calls that have a name
associated with them. For example page('Signup')
would translate to Viewed Signup Page.
UserAgent Addon
Enable this to use the Keen’s data enrichment to parse UserAgent strings.
URL Parsing Addon
Enable this to use the Keen’s data enrichment feature for parsing URLs into its components for easier filtering. Note that userAgent
is only collected on Android, not on iOS.
Write Key
Your write key should be a minimum of 32 characters long and made up of numbers and letters only.
If you have any questions, or see anywhere we can improve our documentation, please let us know!