Intercom Destination

Intercom makes customer messaging apps for sales, marketing, and support, connected on one platform. The Intercom Destination is open-source. You can browse the code for analytics.js, iOS and Android on Github.

This document was last updated on June 12, 2018. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, please let us know!

Getting Started

The first step is to make sure Intercom supports the source type and connection mode you’ve chosen to implement. You can learn more about what dictates the connection modes we support here.

Web

Mobile

Server

📱 Device-based

✅

✅

☁️ Cloud-based

✅

✅

From your Segment UI’s Destinations page click on “Add Destination”.

Search for “Intercom” within the Destinations Catalog and confirm the Source you’d like to connect to.

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. If you have opted to utilize our server-side sources, we will begin passing data through our servers once you activate the Destination. For other libraries please continue reading below.

Find your “App ID” within the Intercom UI following the instructions here or by navigating to the Gear Menu and clicking on “App Settings” followed by “API Keys”. It should look something like this: 9iefb489.

Client

Activate your Intercom Destination and our CDN will be updated within 5-10 minutes.

Mobile

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

Before reading the specific instructions for iOS or Android below, please ensure you enter your Mobile API Key in the Segment Settings UI. This is required to send data to Intercom from your mobile apps.

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

If you haven’t had a chance to review our spec, please take a look to understand what the Page method does. An example call would look like:

analytics.page();

The Page call only works client-side through Analytics.js by triggering the Intercom update method, which will look for new Intercom messages that should be displayed to the current user. It is not supported by any of our server-side or mobile SDKs.

When you call Identify, we create or update a user in Intercom using their Users API. We currently do not support creation of leads.

Note: 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.

Keep reading for more information about the Identify call depending on the source type you send it from.

If a user with traits.company is identified and the company_id does not match a known company, a new company will be created in Intercom. 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. The group call may be used to create/update company profiles explicitly.

Server

When you call Identify from any of the server-side libraries or mobile sources in Cloud Mode 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.

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.

Mobile

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.

Note: 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. In addition, Android traits should be passed using camelCase to conform with Java convention.

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, device_model, os_name, os_version, app_name and app_version.

Track

If you haven’t had a chance to review our spec, please take a look to understand what the Track method does. An example call would look like:

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.

When you call track from any of the server-side libraries or mobile sources in cloud mode (i.e. without our beta Segment mobile Intercom SDK installed), you will need to include either the userId or email of an existing user within Intercom.

Revenue and currency

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

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 active event names. If you are sending Segment more than 120 unique event names, Intercom only accepts the first 120 events that their servers see, and the rest throw an error. In Intercom, an “Active” event is one which has not been archived. If you archive an event, it makes it inactive and removes it from your 120 active events. If you need to bring your account back under the 120 event limit, archive some events from in the Intercom UI by navigating to Settings >data > Events, then click on the event to archive.

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

If you haven’t had a chance to review our spec, please take a look to understand what the Group method does. An example call would look like:

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

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

When you call Group from any of our server-side libraries or mobile sources in cloud mode (i.e. without our beta Segment mobile Intercom SDK installed), you will need to include either the userId or email of an existing user within Intercom.

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

Segment Parameter

Intercom Parameter

Description

groupId

companyId

The ID for the company.

traits.name

name

The name of the company.

traits.plan

plan

The plan of the company.

traits.monthly_spend

monthlySpend

The monthly spend of the company.

traits.company

intercomSettings.company

The company associated for this user.

traits.createdAt

intercomSettings.created_at

The UNIX timestamp when the user was created.

remaining traits

customAttributes

Custom attributes for this user.

Note: 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. In addition, Android traits should be passed using camelCase to conform with Java convention.

Reset

Segment supports Intercom’s reset method only for Device Mode Mobile sources. The bundled mobile SDK’s reset method 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();

Best Practices

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 on identify calls. We will continue to handle that in the same way as before. 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.

Identity Verification

Intercom’s identity verification helps to make sure that conversations between you and your users are kept private and that one user can’t impersonate another. Segment supports identity verification through our analytics.js web library and our iOS and Android mobile sources.

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:

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:

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:

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.

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 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.

I’m seeing a Cannot have more than 120 active event names error

Intercom only allows a total of 120 unique event names. 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 and the rest will throw an error.

If you want to prevent some of your events from being passed to Intercom and thus prevent the error, you can filter out Intercom in those events using the Selecting Destinations feature available on all of our libraries.

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.

If you have any questions, or see anywhere we can improve our documentation, please let us know!