Intercom Destination

Segment makes it easy to send your data to Intercom (and lots of other destinations). Once you've tracked your data through our open source libraries we'll translate and route your data to Intercom in the format they understand. Learn more about how to use Intercom with Segment.

Getting Started

Authorize your Intercom account in Segment and select the Intercom Account you want to sync with Segment. You can choose which account to sync in the drop down menu in the top right.

Now that you have authenticated, activate the Intercom destination.

The server-side component is now ready to go. Other library specific installation steps are listed below:

You will also need to enter an App ID to authenticate the client-side and mobile integrations. You can find your App ID after activating your account under the Gear Menu > App Settings > API Keys at Intercom.com. It should look something like this: 9iefb489.

Analytics.js

Once you have activated the destination, our CDN is updated within 5-10 minutes. Then our snippet will start asynchronously loading Intercom’s library.js onto your page. This means you should remove Intercom’s snippet from your page.

Mobile

Our Intercom mobile components are currently in public beta. We appreciate any feedback you have on the new components, so please let us know!

Enter your Mobile API Key in the integration settings page. This is required to send data to Intercom from your mobile apps.

Android

Add compile 'com.segment.analytics.android.integrations:intercom:+' to your app-level build.gradle file, sync your project, then import the integration in your Application subclass or wherever you’re initializing Segment: import com.segment.analytics.android.integrations.intercom.IntercomIntegration;. Remember to register the IntercomIntegration factory with the Segment SDK:

analytics = new Analytics.Builder(this, "write_key")
  .use(IntercomIntegration.FACTORY)
  .build();

iOS

In your application, add pod 'Segment-Intercom' to your Podfile. After adding the dependency, you must import the integration 'SEGIntercomIntegrationFactory.h' and register it with the Segment SDK [configuration use:[SEGIntercomIntegrationFactory instance]];.

When installing Intercom, you’ll need to make sure that you have a NSPhotoLibraryUsageDescription entry in your Info.plist. This is required by Apple for all apps that access the photo library. It is necessary when installing Intercom due to the image upload functionality. Users will be prompted for the photo library permission only when they tap the image upload button.


Page

Calling page in Analytics.js triggers the Intercom update method, which will look for new Intercom messages that should be displayed to the current user.

The page and screen methods don’t have any effect on Intercom when used from our server-side or mobile SDKs.

If you have the Intercom’s Respond package, simply calling .page() (which is already included in our snippet) will trigger the chat widget to appear. Otherwise, you would need to call identify to make the chat widget appear.

Note: If you have the Respond package and calling page still does not show your chat widget, be sure to check your “Visitors on your website” setting inside your Intercom account!

Identify

Note: Because Intercom only associates Track events with known users, an Identify call with a userId is required before Track events will be associated properly.

Our bundled mobile SDK’s also require that identify be called prior to track, but accepts setting an unknown user in Intercom via the anonymousId.

From the Browser

When you call identify on analytics.js, we create the intercomSettings object and load Intercom’s javascript into the page. Here’s an example identify call that you can send:

analytics.identify('user1234', {
  email: 'teemo@segment.com',
  name: 'Teemo',
  company: {
    id: '813',
    name: 'Teemo Holding Company'
    createdAt: 'Thu Mar 24 2016 17:44:51 GMT+0000 (UTC)'
  },
  createdAt: 'Thu Mar 24 2016 17:46:45 GMT+0000 (UTC)'
});

Here’s how we create the intercomSettings object:

  • The userId parameter (the first argument) is set to intercomSettings.user_id.
  • The traits parameter (the second argument) is set to intercomSettings.custom_attributes.
  • If you send traits.email we set it as intercomSettings.email.
  • If you send traits.name we set it as intercomSettings.name.
  • If you send traits.company we set it as intercomSettings.company.
  • If you send traits.createdAt as a javascript Date object, a valid date string, milliseconds since the epoch, or as seconds like a Unix timestamp, we set intercomSettings.created_at as the unix timestamp in seconds for that created date.

Note: -traits.avatar is read-only. Intercom determines the avatar based on the email address of the user.

  • Passing traits.company will create a new Intercom Company if the company_id does not match a known company. If company is a string, we will set the company_id as a hash of company_name as an id is required to associate the user to the company.
  • Trait values must be no longer than 255 characters

The group call may be used to create/update company profiles explicitly.

Server-Side

When you call identify from any of the server-side or mobile sources (if you are not including the Segment-Intercom SDK), we create or update a user in Intercom. We’ll map our special traits (email, firstName, lastName, createdAt, and company) to Intercom special properties.

If you want to use Intercom’s last_request_at, you’ll need to pass in active: true in the context object. Then, by default we will set last_request_at to the current time; however, if you pass in your own timestamp, pass it in as lastRequestAt (in camelCase), and we’ll set last_request_at to that value in our server-side sources (coming soon on mobile!).

If you want to include last_seen_user_agent then include it in the context.userAgent. Similarly with last_seen_ip which is used for geolocation, you can include the IP address at context.ip. Click here for an example.

Collect Context

With this option selected, identify calls will include contextual information collected by Segment’s mobile libraries if it is available. This info will be set as Custom Attributes on the Intercom user.

The fields collected from the context object are device.type, device.manufacturer, device.model, os.name, os.version, app.name, app.version and will populate in Intercom as device_type, device_manufacturer, etc.

From Mobile

If you are leveraging either of Segment’s mobile SDKs in lieu of the server-side integration, on identify Segment will create or update a user in Intercom.

Intercom supports both logged-in or logged-out users. You will need to register your users with Intercom before you can talk to them or see what they do in your app. This means that identify must be called before track.

Intercom allows users to choose to track only known or only unknown users, as well as both. Segment will support the ability to track both by checking for logged in users (determined by the userId) and falling back to setting the user as “Unidentified” if this is not present.

Intercom knows when your app is backgrounded and comes alive again, so you won’t need to re-register your users.

Segment maps the following Intercom standard attributes on identify.

Intercom ParameterSegment ParameterDescription
emailtraits.emailThe email for this user.
userIdtraits.user_id^The user ID for this user.
nametraits.nameThe name of this user.
phonetraits.phoneThe phone number of this user.
signedUpAttraits.created_at^The signed up date for this user as an NSDate in iOS and Long on Android
languageOverrideintegrations.intercom.language_overrideThe language override code for this user. languageOverride must be a valid language code. For more information see here
unsubscribedFromEmailsintegrations.intercom.unsubscribedA boolean indicating if the user has unsubscribed from emails.
companiestraits.companyThe companies for this user. See group for more details on which company attributes we map to.
customAttributeswhatever remains in traitsCustom attributes for this user. Intercom only supports values of type NSString, NSNumber or NSNull on iOS and String, Long, Float, Double, Boolean, Character, Byte, Short or Integer on Android.

^Android traits should be passed using camelCase to conform with Java convention.

Track

Revenue and currency

Segment supports Intercom events in all of our sources through the track method.

If you send properties.revenue and properties.currency, we will format that according to Intercom’s Monetary Amount and send it as:

price: {
  amount: <properties.revenue> * 100, // since Intercom requires this in cents
  currency: <properties.currency> // will default to 'usd'
}

Our bundled mobile integrations will also check properties.total if properties.revenue is not present, and assign the total value as the amount value.

Limited Properties

Intercom can only store 5 event properties per event. That means if you send an event to Segment with more than 5 properties, Intercom will only show the first 5 properties.

Limited Events

Intercom only allows a total of 120 unique event names (see the questions titled “Is there a limit on the number of event types I can send?”). That means if you are sending Segment more than 120 unique event names, Intercom will only accept the first 120 events that hit their servers.

Server-side Race Condition

Because our server-side libraries batch calls by default, it may happen that an Identify call intended to create a user arrives simultaneously with a Track event associated with this user. If the Track event is processed before the user is created, an error will result and the event will not be recorded.

Adding a Flush method immediately following the Identify, and before any subsequent Track event, will help the Identify call reach Intercom first to create the user. Generally, this prevents the race condition, but an additional timeout can be used if necessary.

Group

Segment supports Intercom companies in all of our sources through the group method. Users can be put into multiple groups, which will associate them to multiple companies in Intercom.

analytics.group('companyId123', {
  name: 'Segment'
});

Note: In order for the Company Sessions Count to update within Intercom, the company must first be recorded in an identify call.

Intercom ParameterSegment ParameterDescription
companyIdgroupIdThe ID of the company.
nametraits.nameThe name of the company.
monthlySpendtraits.monthly_spend^The monthly spend of the company.
plantraits.planThe plan of the company.
customAttributeswhatever remains in traitsCustom attributes for this user. For iOS, each key must be an NSString and each value must be of type NSString, NSNumber or NSNull on iOS or String, Long, Float, Double, Boolean, Character, Byte, Short or Integer on Android.

^Android traits should be passed using camelCase to conform with Java convention.

Reset

The bundled mobile SDK’s support reset which unregisters a user in Intercom. When users want to log out of your app and you call Segment’s reset method, Segment will call:

On iOS:

  [Intercom reset];

On Android:

  Analytics.with(context).reset();

Features

Arrays and Objects

Intercom does not support custom arrays or objects. Per Intercom’s request, we removed support for this feature starting Aug 21st, 2017. This means that if you want a certain user trait or event property to be sent to Intercom, you must send them at the top level.

This limitation does not apply however for mapping company objects. We will continue to handle that in the same way. This is only applicable for any custom traits or properties.

Disassociating Users from a Company (server-side only)

You can disassociate a user from a company by passing in a field inside the company trait with remove: true in your identify calls.

analytics.identify({
  userId: '019mr8mf4r',
  traits: {
    name: 'Michael Bolton',
    email: 'mbolton@initech.com',
    plan: 'Enterprise',
    company: {
      id: 12345,
      remove: true
    }
  }
});

Identity Verification

For mobile apps, before enabling identity verification, please read Intercom’s docs on identity verification. An important note from the Intercom docs:

If you have already started sending events to Intercom, but have not enabled identity verification, then enabling it after will stop old versions of your app communicating with Intercom. We recommend that you complete setting up identity verification and test that everything is working. Then turn off identity verification and release an update to your app. This update will be sending user hashes to Intercom but not enforcing it. Once you are happy with the number of users on versions of your app sending the user hash you can come back and toggle identity verification on which will then start enforcing it for all versions of your app.

If you want to enable Intercom identity verification for analytics.js or our bundled mobile SDKs, you can pass in the user_hash variable inside the context object.

The user_hash should be a SHA256 hash of your Intercom API secret and the userId. The hash is not based on the email, it’s based on the userId. Here’s an example rendering an identify call with identity verification:

analytics.identify('<%= current_user.id %>', {
    email: '<%= current_user.email %>',
    createdAt: '<%= current_user.created %>'
}, {
     Intercom: {
        user_hash: '<%= OpenSSL::HMAC.hexdigest("sha256", "YOUR_INTERCOM_APP_SECRET", current_user.id) %>'
     }
});

Android example:

Traits traits = new Traits();
Map<String, Object> intercomOptions = new HashMap<>();
intercomOptions.put("userHash", "YOUR_USER_HASH");
Options options = new Options().setIntegrationOptions("Intercom", intercomOptions);
Analytics.with(context).identify("123", traits, options);

YOUR_INTERCOM_APP_SECRET is found in Intercom’s identity verification setup guide.

Identity verification plus filtering via Destinations Object

If using Intercom identity verification AND selective destinations functionality, the context object will look like this:

{
     integrations: {
         All: false,
         Intercom: {
            user_hash: '<%= OpenSSL::HMAC.hexdigest("sha256", "YOUR_INTERCOM_APP_SECRET", current_user.id) %>'
         }
     }
}

Unsubscribe Users

To unsubscribe users from emails, you may set a flag from server side libraries, unsubscribedFromEmails, inside context object:

node.js example:

analytics.identify({
  userId: '4832094283057439285723523452345',
  anonymousId:'43254364571',
  context:{
    Intercom: { unsubscribedFromEmails: true }
  },
  traits: {
    firstName: 'John ',
    lastName: 'Jacob',
    email: 'jingleheimer@schmidt.com'
  }
});

objective-c example:

options:@{
  @"integrations": @{
   @"intercom" : @{
     @"unsubscribed": @YES
    }
  }
}

Android example:

Traits traits = new Traits();
Map<String, Object> intercomOptions = new HashMap<>();
intercomOptions.put("unsubscribedFromEmails", true);
Options options = new Options().setIntegrationOptions("Intercom", intercomOptions);
Analytics.with(context).identify("123", traits, options);

Note: This will only work from server side libraries and bundled mobile. NOT analytics.js.

Last Seen

By default Intercom updates the Last Seen user trait whenever a user’s profile is updated by identify calls, or if a group call is sent with a user’s userId. If you want to update a user without updating their Last Seen time, pass active with a value of false into the context (see example below) of your identify or group calls.

Note that this only works server-side; Last Seen will always be updated client-side. Please note that id or name are necessary to update company.

Here’s a full python example of an identify call with active set to false:

analytics.identify(user_id='some_user_id', traits={
    "email": "ben@intercom.io",
    "firstName": "Ben",
    "lastName": "McRedmond"
    "createdAt": 1363902294011,
    "plan": "Premium"
}, context={
    "ip": "192.168.0.1",
    "active": False,
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.47 Safari/537.36"
})

Intercom Tags

Our API doesn’t support Intercom tags. Traits can be used instead of tags to create segments of users, and the advantage is you can use those traits in other destinations like Segment.

Conditionally show the Intercom chat widget (Browser only)

You can take advantage of Intercom’s hide_default_launcher option to selectively show the chat widget. According to Intercom’s docs, you want to first hide the Messenger for all users inside their UI via Messenger settings. Then think about how you want to programmatically decide which users you’d like to show the widget to. Then you can pass an Intercom specific destination setting like this:

// with analytics.js
analytics.identify('teemo', { someTrait: 'x'}, {
  Intercom: { hideDefaultLauncher: true }
});

Note: You can pass in the Intercom specific option via all supported calls for this destination (page, identify, and group)!

Control the Intercom Chat Widget (Mobile only)

Our mobile SDKs give you the ability to tap into the Intercom instance our integration creates so that you can call any of Intercom’s native’ methods on it. This includes all methods required to interact with the Intercom chat widget.

Here’s an example of how to grab the underlying Intercom instance.

On Android:

analytics.onIntegrationReady("Intercom", new Callback() {
  @Override public void onReady(Object instance) {
    Intercom intercom = (Intercom) instance;
  }
});
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(integrationDidStart:) name:SEGAnalyticsIntegrationDidStart object:nil];

- (void)integrationDidStart:(nonnull NSNotification *)notification
{
    NSString *integration = notification.object;

    if ([integration.name isEqualToString:@"Intercom"]) {
        // Call Intercom library methods here.
    }
}

You can read more about tapping into destination-specific methods on Android here and on iOS here.

Push notification and deep linking

Our mobile SDKs do not support push notifications and deep linking out of the box. Refer to the Intercom documentation here and here for more information on setting up push notifications and deep linking on iOS and here and here for more information on these features on Android. Note our Android SDK bundles Intercom’s Firebase push notification dependency, and cannot support Google Cloud Messaging push notifications at this time.


Troubleshooting

I’m seeing a 403 Forbidden error

You probably have Intercom’s identity verification setting turned on but are not passing the user_hash correctly or at all.

You may also have to whitelist your domain in Intercom’s dashboard. Otherwise, events on non-whitelisted pages may be rejected with a 403 error.

My Intercom Widget doesn’t show up

Make sure you are sending a page and identify call when the page is loaded. This allows Intercom to register the page and the user, which would enable the widget to appear.

If you are sending those two calls, then check that the CSS selector for the widget is correct. The default is #IntercomDefaultWidget, but if you customize your widget, then be sure to update this field accordingly.

My client-side and server-side calls are going to one Segment source, but different Intercom projects

Server-side calls go the the project selected when you authenticated your Intercom account while setting up the destination. Client-side calls go to the project referenced with the App ID setting. Make sure those projects are the same.


Supported Sources and Connection Modes

WebMobileServer
📱 Device-based
☁️ Cloud-based

To learn more about about Connection Modes and what dictates which we support, see here.

Segment offers an optional Device-based Connection Mode for Mobile data with Intercom. If you’d like to use those features that require client-based functionality, follow the steps above to ensure you have packaged the Intercom SDK with Segment’s.

Settings

Segment lets you change these destination settings via your Segment dashboard without having to touch any code.

Custom Inbox Button Selector

By default, Intercom will inject their own inbox button onto the page, but you can choose to use your own custom button instead by providing a CSS selector like: #my-button. Note: you must have enabled the Show the Intercom Inbox setting for this to work. The default value is #IntercomDefaultWidget

Enter your API Key

Note: this is deprecated . Intercom requires events hitting their server-side api authenticated via OAuth.

App ID (required for analytics.js and mobile)

Note: this is required to send data to Intercom from your browser or mobile app. You can find your App ID after activating your account under the Gear Menu > App Settings > API Keys at Intercom.io. It should look something like this: 9iefb489.

Include Context with Identify Calls

Pass context data with Identify calls as Custom Attributes. Includes device.type, device.manufacturer, device.model, os.name, os.version, app.name, app.version

isBulkAPIEnabled

Enter your Mobile API Key

Note: this is required to send data to Intercom from your mobile apps.

OAuth

Intercom uses an OAuth-like interface for reading/writing to their system. This option stores the various values that are needed by Intercom to validate requests (replaces API keys), and the user-specific values for UI display (e.g. user’s email, avatar, list of accounts, etc.). These fields are unique to Intercom, and are cleared out en masse when disconnecting (revoking authorization).

To use Intercom’s Rich Link object, list the name of the exact Segment property name and make sure the value of those properties only include url and value keys.


If you have any questions or see anywhere we can improve our documentation, please let us know or kick off a conversation in the Segment Community!