Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Intercom Destination


Intercom(link takes you to an external page) makes customer messaging apps for sales, marketing, and support, connected on one platform. The Intercom Destination Plugin is open-source. You can browse the Swift code for iOS(link takes you to an external page) on GitHub.


Getting started

getting-started page anchor
  1. From the Segment Destinations page click Add Destination.
  2. Search for "Intercom" and select it from the results that appear.
  3. Select a source to connect to your Intercom destination.
  4. Authorize your Intercom account in Segment and select the Intercom Account to sync with Segment. You can choose which account to sync from the drop down menu in the top right. If you are using server-side sources, Segment starts passing data through once you activate the Destination. For other libraries, continue reading.
  5. Find your "App ID" in the Intercom UI(link takes you to an external page) or by navigating to the Gear Menu and selecting App Settings > API Keys. It should look something like 9iefb489.

Your changes appear in the Segment CDN in about 45 minutes, and then Analytics.js starts asynchronously loading Intercom's library.js onto your page.

After your changes appear in Segment's CDN, you should remove Intercom's snippet from your page.


(warning)

Warning

The Intercom library itself will be installed as an additional dependency.

Xcode

xcode page anchor

In the Xcode File menu, click Add Packages. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repo.

https://github.com/segment-integrations/analytics-swift-intercom

You then have the option to pin to a version or specific branch and select which project in your workspace to add the package to. Once you've made your selections, click the Add Package button.

Open your Package.swift file and add the following to the dependencies section:

1
.package(
2
name: "Segment",
3
url: "https://github.com/segment-integrations/analytics-swift-intercom.git",
4
from: "1.1.3"
5
),

Using the plugin in your app

using-the-plugin-in-your-app page anchor

Open the file where you set up and configured the Analytics-Swift library. Add this plugin to the list of imports.

1
import Segment
2
import SegmentIntercom // <-- Add this line

Just under your Analytics-Swift library setup, call analytics.add(plugin: ...) to add an instance of the plugin to the Analytics timeline.

1
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
2
.flushAt(3)
3
.trackApplicationLifecycleEvents(true))
4
analytics.add(plugin: IntercomDestination())

Your events will now start to flow to Intercom in device mode.


If you're not familiar with the Segment Spec, take a look to understand what the Identify method does. An example call would look like:

1
struct MyTraits: Codable {
2
let name: String
3
let email: String
4
let company: [String: String]()
5
let createdAt: String
6
}
7
8
analytics.identify(userId: "a user's id", MyTraits(
9
name: "Iñigo Montoya",
10
email: "avenger@example.com",
11
company: {
12
id: '123',
13
name: "Iñigo & Friends Holding Company"
14
},
15
createdAt: "Mon Mar 26 2018 17:44:51 GMT+0000 (UTC)"
16
))

When you call Identify, Segment creates or updates the user in Intercom using Intercom's Contacts API(link takes you to an external page). Segment does not currently support creating leads(link takes you to an external page). Passing traits.company creates a new Intercom Company if the company_id does not match an existing company_id. See the Intercom contact model documentation(link takes you to an external page) for more details.

(information)

Intercom associates Track events with known users

An Identify call with a userId is required before Track events are associated properly. Segment's bundled mobile SDKs also require that Identify be called prior to Track, but accepts setting an unknown user in Intercom using the anonymousId.

Intercom allows you to track only known or only unknown users, or all users regardless of identification status. Segment supports the ability to track all users regardless of identification status by checking for logged in users (determined by the userId) and falling back to setting the user as "Unidentified" when 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 calls:

Segment ParameterIntercom ParameterDescription
traits.userIduser_idThe user ID for this user.
traits.emailemailThe email of this user.
traits.namenameThe full name of this user.
traits.phonephoneThe phone number for this user.
traits.companycompanyThe company associated for this user.
traits.signedUpAtcreated_atThe signed up date as an NSDate (iOS) & Long (Android)
integrations.intercom.language_overridelanguageOverrideThe language override(link takes you to an external page) code for this user.
integrations.intercom.unsubscribedunsubscribedFromEmailsA boolean indicating if the user has unsubscribed from emails.
remaining traitscustomAttributesCustom attributes for this user.
(information)

Info

Intercom supports NSString, NSNumber or NSNull type values on iOS.

Collect context

collect-context page anchor

When this option is selected, Identify calls include contextual information collected by Segment's mobile libraries if it is available. This info is 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 appear in Intercom as device_type, device_manufacturer, device_model, os_name, os_version, app_name and app_version.


If you're not familiar with the Segment Spec, take a look to understand what the Track method does. An example call would look like:

1
struct OrderCompletedProperties: Codable {
2
let order_ID: String
3
let category: String
4
let productName: String
5
let price: Double
6
let currency: String
7
}
8
9
analytics.track(name: "Product Purchased", properties: OrderCompletedProperties(
10
order_ID: "2969302398",
11
category: "boots",
12
product_name: "yellow_cowboy_boots",
13
price: 99.95,
14
currency: "EUR"))
(information)

Info

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

When you make a Track call from any of the server-side libraries or mobile sources in cloud-mode (for example, without the beta Segment mobile Intercom SDK installed), you must include either the userId or email of a user already recorded in Intercom.

Revenue and currency properties

revenue-and-currency-properties page anchor

If you send properties.revenue and properties.currency to Intercom, Segment formats those properties according to Intercom's Monetary Amount(link takes you to an external page) and sends them to Segment as:

1
price: {
2
amount: <properties.revenue> * 100, // since Intercom requires this in cents
3
currency: <properties.currency> // defaults to 'usd'
4
}

If properties.revenue is not present, the bundled mobile integrations check properties.total and assign the total value as the properties.revenue or amount value.

Intercom can only store 5 event properties(link takes you to an external page) per event. If you send an event to Segment with more than 5 properties, Intercom only shows the first 5 properties.

Intercom only allows a total of 120 unique active event names. If you're 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 an event that hasn't been archived. Intercom only allows a total of 120 unique active event names. If you're sending Segment more than 120 unique event names, Intercom only accepts the first 120 events that their servers encounter. Any additional unique event names will result in an error.

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 > (workspace name) data > Events, then click on the event to archive.


If you're not familiar with the Segment Spec, take a look to understand what the Group method does. An example call would look like:

1
struct MyTraits: Codable {
2
let username: String
3
let email: String
4
let plan: String
5
}
6
7
// ...
8
9
analytics.group(groupId: "group123", traits: MyTraits(
10
username: "MisterWhiskers",
11
email: "hello@test.com",
12
plan: "premium"))

Segment supports Intercom company values sent from all source types. Users can be put into multiple groups, which associate them to multiple companies in Intercom.

When you call Group from any of any server-side libraries or mobile sources in cloud-mode (without Segment's mobile Intercom SDK installed), you must include either the userId or email of an existing user in Intercom.

(information)

Info

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

Segment ParameterIntercom ParameterDescription
groupIdcompanyIdThe ID for the company.
traits.namenameThe name of the company.
traits.planplanThe plan of the company.
traits.monthly_spendmonthlySpendThe monthly spend of the company.
traits.companyintercomSettings.companyThe company associated for this user.
traits.createdAtintercomSettings.created_atThe UNIX timestamp when the user was created.
remaining traitscustomAttributesCustom attributes for this user.
(information)

Info

Intercom supports NSString, NSNumber or NSNull type values on iOS.


The bundled mobile SDK reset method un-registers a user in Intercom. When users want to log out of your app and you call Segment's reset method, Segment calls:

Intercom.logout()

Intercom doesn't support custom arrays or objects. If you want to send a certain user trait or event property to Intercom, you must send them at the top level instead of in an array or object.

This limitation does not apply when you are mapping custom traits or properties to company objects on Identify calls. Segment continues to handle this in the same way as before. This is only applicable for custom traits or properties.