Moesif Segment Plugin
The Segment integration is installed simply by connecting your Moesif account to your Segment account and doesn’t require any code changes. The integration can be used both as a Segment destination and a source.
Segment destination
As a Segment destination, Segment will sync user traits and tracked events to Moesif. Moesif also associates your web activity to API traffic so you can analyze the end to end customer journey and funnel metrics.
Use the Moesif API Analytics Destination if you want to:
- Enrich users in Moesif to understand API usage by acquisition channels and customer demographics.
- Correlate API calls in Moesif with events tracked by Segment
- Track funnel metrics like Time to First Hello World (TTFHW) and conversion rate
The below Diagram shows how both Segment and a Moesif server integration to track both web and API traffic made by a customer.
For more info, see Moesif Segment Destination.
Segment source
As a Segment source, Moesif will sync Moesif user profiles and their API metrics to Segment.
Use the Moesif API Analytics Source if you want to:
- Track API usage in tools like Amplitude and Mixpanel.
- Trigger email sequences in tools like HubSpot like when customers approach rate limits.
- See trial or pilot usage in your CRM to prioritize customer outreach.
Segment is not required to view Moesif data in your sales and marketing tools. Moesif has a variety of extensions for tools like Salesforce and HubSpot.
For more info, see Moesif Segment Source.
How to install
Segment destination
- From your Segment UI’s Destinations page click on “Add Destination”.
- Search for “Moesif” within the Destinations Catalog and confirm the Source you’d like to connect to.
- Enter the Moesif “API Key” into the destinations settings in the Segment App. You can find these by going to your Moesif account account and navigating to the extensions settings.
- Once integrated, Segment data shows up in Moesif in a few seconds.
If not done already, associate API calls to a user id by implementing the
identifyUser()
hook for your respective server integration. This should be the same id you use when calling Segment’s identify() method.
Segment source
- From your Segment UI’s Sources page click on “Add Source”.
- Select Moesif API Analytics within the Source Catalog and confirm adding the source.
- Give the Source a nickname and follow the setup flow to “Add Source”.
- Copy the Write Key from the added source. You’ll need this later in Moesif.
- Log into your Moesif account, go to the Settings menu and click Extensions.
- Select the Segment Extension within the extensions gallery and add your write key under Add Partner Key.
How it works
Segment destination
The Segment destination can be used instead of moesif-browser-js
directly to track web activity and supports both identify
and track
to Moesif.
Identify
Segment sends identify() calls to Moesif as user updates. If you set traits.company.id
on the user, Moesif also associates it with a company. The integration maps user fields as follows:
Segment Field | Moesif Field |
userId |
user_id |
traits |
metadata |
traits.company.id |
company_id |
The integration handles Segment reserved traits like email
and firstName
. It also maps automatically-collected fields like campaign information and IP address.
Track
Segment sends track() calls to Moesif as tracked custom actions which you can see in the Events section in Moesif. As an example, you can use Segment’s analytics.js to track when the login button is clicked:
analytics.track('Login Button Clicked')
The integration maps event fields as follows:
Segment Field | Moesif Field |
event |
action_name |
properties |
metadata |
Both Segment and Moesif support automatic anonymous user tracking. You should only call identify
with an actual user id.
Segment source
The segment source will periodically sync user profiles in Moesif to Segment as user traits via a identify() message.
Because API calls contain a very large number of fields and values, they cannot be ingested in a UI event tracking tool like Segment or Amplitude directly as they’re not designed for API data. Instead, Moesif rolls up API usage metrics and adds to the user as a user trait called last24HourAggResults
.
Identify Message
Field | Type | Description |
---|---|---|
userId |
String | Unique identifier for the user in Moesif |
context |
Object | User context like IP address and location. |
traits |
Object | Custom traits of the user (See Traits Object) |
Traits Object
The integration maps user metadata in Moesif to the Segment trait called metadata
.
If the user was linked to a company in Moesif, the integration will map the associated company to a Segment trait called company
.
Field | Type | Description |
---|---|---|
id |
String | User Id (Same as userId in parent object) |
createdAt |
Date | Time when user was created in Moesif |
modifiedTime |
Date | Time when user was last modified |
firstSeenTime |
Date | Time user was first seen on the API |
lastSeenTime |
Date | Time user was last seen on the API |
name |
String | User’s Full Name |
email |
String | User’s email |
username |
String | Username such as a Twitter handle |
company |
Object | Company in Moesif (See Company Object) |
campaign |
Object | Marketing campaign attribution like UTM parameters |
enrichment |
Object | Auto-enrichment lookup results for the user |
company |
Object | Associated company in Moesif (See Company Object) |
last24HourAggResults |
Object | Rollup of user’s API activity from last 24 hours |
metadata |
Object | Your user metadata |
userAgent |
Object | Last user agent details |
Company Object
Info for the associated company. Any company metadata set in Moesif is mapped to the Segment trait company.metadata
Field | Type | Description |
---|---|---|
id |
String | Unique identifier for the company in Moesif |
created |
Date | Time when company was created in Moesif |
modifiedTime |
Date | Time when company was last modified |
firstSeenTime |
Date | Time user was first seen on the API |
lastSeenTime |
Date | Time user was last seen on the API |
ipAddress |
String | Company’s last IP address |
companyDomain |
String | Company’s website domain |
ttfhw_s |
Integer | Time to First Hello World in seconds |
metadata |
Object | Your company metadata |