Segmentation - Grouping your customers

A key part of your CRM process is being able to segment your customers into smaller subsets. These subsets represents more defined groupings of customers into different potential markets. You may want to target customers based on their demographic profile or based on their customer service interaction or their purchasing history. No matter what the criteria, the better you can define these groupings the more personalised you can make your messaging to these segments.

Overview: What are segments, tags and companies

When people talk about CRMs they generally use the catch-all term segmentation to refer to the ability to identify groups of customers. This is true regardless of the category or the type of grouping you want to be perform. In order to be able to perform this type of segmentation in Intercom you first need to know the different ways you can group customers in Intercom. Once you know the different ways you can group your customers in Intercom you can choose one or more of those methods and tailor them towards your own requirements to identify new market segments.

720

How segments, tags and companies can group resources in Intercom

The above diagram shows the difference between tags, segments and companies at a high level.

First you need to understand what resources you want to group.

  • If you want to group your conversations you will need to use tags.
  • Leads, users and companies can be tagged or filtered via segments or grouped within a company

Then you will need to understand what type of grouping you need:

  • If you want to identify something to manually review later, e.g. a feature request then you could use tags
  • If you would like an automatically updated list of current trial users then segments would be useful
  • Alternatively, if you want to add more context to a group within the same org or geographical area then companies could be the easiest way to do this
    To make it easier to know which format to use to group your customers we can now look at the functionality of these features.

Functionality: What can you do with segments, tag and companies

Once you have a good understanding of the different ways you can group resources in Intercom you will need more information on the specific functionality of each method. For example, you may need to know whether you can use it via the API or use it to message people. The table below should help to clarify this.

TypeCreate via APIList, view via APIGroup your ConversationsGroup leads/users, companiesUse with auto messages(UI)Add group specific attributes
Segments No*YesNoYesYesNo
Tags YesYesYesYesYesNo
Companies YesYesYesYesYesYes

* Segments cannot be created via the API. You need to create them via the UI.

Are companies really a group feature?

It might seem strange to see companies in the same feature set as segments and tags. Companies are different from resources such as leads and users in that they are a container of people and you can associate attributes with that container and you can also do things like message everyone in a company (via the UI). You can also do things such as tag companies and segments so it can be a very versatile container to identify particular customer segments.

Example: How do I get customers in my segments or tags?

One example of how you might group customers is for offline processing. You might want to build up a group of customers based on their behaviour over a period of a month. Then at then end of the month you want to get the list of these customers and look for patterns or trends for these users. Maybe it is customers who opened X number of conversations in a month or unsubscribed from a service. Either way you want to see if there is something you can learn from these customers.

Creating your segments

First things first, you will want to setup your segments or tags. As noted you can see how to setup your segment via the UI here. You might want to add users based on the last time they were active or the fact that they triggered an unsubscribe event for example:

494

Create your tags

You can create your tags via the API. Continuing with the offline example, you may want to tag potential sales leads. These may be tagged manually by your customer service team as they chat to customers and feel that they would benefit from speaking to someone on your sales team:

788

First select the lead

1000

Then simply click on the 'Tag' button to either create a new tag or add to an existing one

You can also tag resources via the API, when you use the API to tag a resource you will create a new tag if it does not exist.

🚧

Use ID for leads

If you are tagging leads you will need to use the Intercom ID. For users you can use either the ID, user_id or email.

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
var tag = process.argv[2];
var tag_user = process.argv[3];
// Using the ID (value in the URL) you can tag either users or leads. 
// If you use user_id or email you can only tag users
client.tags.tag({name: tag, users: [{ id: tag_user }] }, function (rsp){
  console.log(rsp.body)
});
> node tag_user.js value_lead '4b041896db50f992a0d4df2c'
// You can tag a list of users and leads in one go if you like
client.tags.tag({name: tag, users: [{ user_id: tag_user }, {id: tag_lead}, {email: user_email}] }, function (rsp){
    console.log(rsp.body)
});

Find the customers you just tagged or added to a segment

Now that you know how to add customers to your segments and tags you will want to be able to discover which of you customers are in these new groupings. There are three main actions you will want to perform on tags or segments. You can see these actions outlined in the diagram here:

720

The actions and associated endpoints for tags and segments

The actions are:

  • List your tags or segments: This action will list all the tags or segments you have created for your app. In the list returned you will be able to see the ID associated with the relevant tag or segment. This is very important since you need this ID to get the list of resources associated with that record.
  • List the customers in your tag/segment: To list the customers in your tag or your segment you will need to know the tag or segment ID. Then you can go to the users endpoint and retrieve the users associated with that resource
  • Get the counts of your tags/segments: You may just want to get a global count of all your tags, segments or companies. You can do this using the counts endpoint

Get the counts of your tag and segments

To look at how many resources are in our tags or segments we can use the count endpoint as follows:

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });

client.counts.userTagCounts(function (rsp){
    console.log(rsp.body.user)
});
> node count_user_tags

{ tag:
   [ {'multi-id': 3 },
     { tag_test: 1 },
     { tag_test2: 0 },
     { tag1: 0 },
     { tag2: 0 },
     { value_lead: 3 } ] }
// To get segment counts just replace the call with 
//client.counts.userSegmentCounts(callback)
var Intercom = require('intercom-client');
var client = new Intercom.Client({ token: process.env['AT'] });

client.counts.userSegmentCounts(function (rsp){
    console.log(rsp.body.user)
});

Get the customers in your tags and segments

So far we have created segments and tags and from the counts we can see whether these tags and segments have been populated. The next step is to list the customers that are in these tags or segments. As you can see from the diagram above this is a two step process:

  • First get the ID associated with the tag or segment you are interested in
  • Next go to the users endpoint and use the ID to list the users associated with that tag or segment
789

Get the list of tags/segments and then use the ID to get the list of users

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
client.tags.list(function (rsp){
    console.log(rsp.body)
});
{ type: 'tag.list',
  tags:
   [ { type: 'tag', id: '1174399', name: 'multi-id' },
     { type: 'tag', id: '730128', name: 'tag_test' },
     { type: 'tag', id: '1028594', name: 'tag_test2' },
     { type: 'tag', id: '1201455', name: 'tag1' },
     { type: 'tag', id: '1201457', name: 'tag2' },
     { type: 'tag', id: '1373897', name: 'value_lead' } ] }
var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
var tag_id = process.argv[2];
client.users.listBy({tag_id: tag_id}, function (rsp){
    console.log(rsp.body)
});
> node list_users.js '1373897'

# Returns a list containing all the customers (leads and/or users) in the tag
{ type: 'user.list',
  pages:
   { type: 'pages',
     next: null,
     page: 1,
     per_page: 50,
     total_pages: 1 },
  users:
   [ { type: 'contact',
       id: '5a041896db50f992a0d4df1b',
       user_id: '24cfe3d6-fc76-4b39-993d-b2642b2336fb',
			 ..... (Full user object) ...
       custom_attributes: {} },
     { type: 'user',
       id: '59cbaaa693394ffc43250e67',
       user_id: '199',
       anonymous: false,
			 ..... (Full user object) ...
       custom_attributes: [Object] },
     { type: 'user',
       id: '58a69fae97d20491073d10fc',
       user_id: '1234',
       anonymous: false,
			 ..... (Full user object) ...
       custom_attributes: {} } ],
  total_count: 3
  }
// To get the same for segments simply replace 'tag' with 'segments'
// e.g. to get list of segments
client.segments.list(function (rsp){
    console.log(rsp.body)
});

// Returns lists of segments
{ type: 'segment.list',
  segments:
   [ { type: 'segment',
       id: '58135df83917e42135b2ea29',
       name: 'Active',
       created_at: 1477664248,
       updated_at: 1510220315,
       person_type: 'user' },
     { type: 'segment',
       id: '58135df83917e42135b2ea28',
       name: 'New',
       created_at: 1477664248,
       updated_at: 1508743608,
       person_type: 'user' },
     { type: 'segment',
       id: '59513180ac9c4dd91ec06530',
       name: 'PHILOSOPHERS',
       created_at: 1498493312,
       updated_at: 1506340076,
       person_type: 'user' },
     { type: 'segment',
       id: '58135df83917e42135b2ea2a',
       name: 'Slipping Away',
       created_at: 1477664248,
       updated_at: 1477664248,
       person_type: 'user' }] }


// And to get the list of customers in a segment
client.users.listBy({segment_id: tag_id}, function (rsp){
    console.log(rsp.body)
});
// Returns same output as tags

Example: How do I list customers in a company?

We can follow a similar process to show how to list people that belong to a certain company. First we need to know how to create companies and add users to those companies. Then we can look at how to list the people that are associated with that company

720

The actions and associated endpoints for using companies

Add people to a company

If you add people to a company that does not exist it will be created. So you can create and update a company all in one go. While you can create a company from the companies endpoint it is easier to simply add users to a company. If the company does not exist then it will be created.

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
var cust_id = process.argv[2];
var comp_id = process.argv[3];
var comp_name = process.argv[4];

var customer_data = {
  id: cust_id,
  companies: [
    {
      "company_id" : comp_id,
      "name" : comp_name
    }
  ]};

client.users.create(customer_data, function (rsp){
  console.log(rsp.body)
});
// You can do this multiple times to add more than one user
// Or simply add a list of users in one go
node add_to_company.js '5a03e2d33e69b29660557c9f' '1178' 'Mitch_and_Murray'
{ type: 'user',
  id: '4a02c2d33e69b29660557b6d',
  user_id: '0',
  anonymous: false,
  email: '[email protected]',
  phone: null,
  name: 'Test User',
  companies:
  { type: 'company.list',
  companies:
   [ { type: 'company',
       company_id: '1178',
       id: '5a047e7c937c888ae37def04',
       name: 'Mitch_and_Murray' } ] }
  ..... (Full user object) .......
  tags: { type: 'tag.list', tags: [] },
  segments: { type: 'segment.list', segments: [ [Object], [Object] ] },
  custom_attributes: {} }

❗️

Empty companies in UI and API lists?

If you create a company with no customers associated with it then you will not be able to see it in the UI or list it via the API. You must have someone in the company to be able to list it.

List companies and get user counts

Now that we have created a company by associating users with it we can list our companies and then get the counts associated with those companies.

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
client.companies.list(function (rsp){
  console.log(rsp.body)
});
// List the companies to get all the companies 
> node list_companies.js

{ type: 'company.list',
  pages:
   { type: 'pages',
     next: null,
     page: 1,
     per_page: 15,
     total_pages: 1 },
  companies:
   [ { type: 'company',
       company_id: '1178',
       id: '5a047e7c937c888ae37def04',
       app_id: 'fyq3wodw',
       name: 'Mitch_and_Murray',
       created_at: 1510243964,
       updated_at: 1510245247,
       last_request_at: 1510245060,
       monthly_spend: 0,
       session_count: 0,
       user_count: 3,
       tags: [Object],
       segments: [Object],
       plan: {},
       custom_attributes: [Object] },
     { type: 'company',
       company_id: '11',
       id: '59945bb33791c186d0f93fbb',
       app_id: 'fyq3wodw',
       name: 'Hydra2',
       created_at: 1502895027,
       updated_at: 1505481751,
       last_request_at: 1500288932,
       monthly_spend: 0,
       session_count: 0,
       user_count: 2,
       tags: [Object],
       segments: [Object],
       plan: [Object],
       custom_attributes: {} },
       .... (list of all full company objects) ....
       ....
       ....
    ],
  total_count: 10 }
var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
client.counts.companyUserCounts(function (rsp){
  console.log(rsp.body)
});
> node count_companies.js
{ user:
   [ { ACME: 0, remote_company_id: '234' },
     { Intercom: 1, remote_company_id: '5' },
     { Test Company: 0, remote_company_id: '9' },
     { Academy: 1, remote_company_id: '10' },
     { Hydra: 1, remote_company_id: 'hydra' },
     { Hydra2: 2, remote_company_id: '11' },
     { Serenity: 1, remote_company_id: '366' },
     { Hydra5: 1, remote_company_id: '79' },
     { Mitch_and_Murray: 3, remote_company_id: '1178' },
     { Acme: 0, remote_company_id: '1121' } ] }
// Remember you can also tag companies 
// so you can list them by tag or segment id 
client.companies.listBy({ tag_id: 'haven' }, callback);
client.companies.listBy({ segment_id: 'haven' }, callback);

// You can also get the counts for these company tags and segments
client.counts.companyTagCounts(callback);
client.counts.companySegmentCounts(callback);

🚧

Empty companies in counts?

Notice that you can see the companies with no users associated with them when you list the companies via the counts endpoint

List all the users in a company

So far we have associated users with companies and been able to list all our companies and even check the number of users associated with these companies. We can now finally list all the users associated with a particular company

var Intercom = require('intercom-client');

var client = new Intercom.Client({ token: process.env['AT'] });
var comp_id = process.argv[2];

// List users in the company using ID (i.e. not company ID)
client.companies.listUsers({ id: comp_id }, function(rsp){
  console.log(rsp.body)
});
> node list_company_users.js 5a047e7c937c888ae37def04

# Returns a list of full user objects
{ type: 'user.list',
  pages:
   { type: 'pages',
     next: null,
     page: 1,
     per_page: 50,
     total_pages: 1 },
  users:
   [ { type: 'user',
       id: '23ca7c87d4c42de1156ef9e4',
       user_id: '124',
       anonymous: false,
       email: '[email protected]',
       phone: null,
       name: 'bobr',
       pseudonym: null,
       avatar: [Object],
       app_id: 'fyq3wodw',
       companies: [Object],
			 .... (full user object) ...
     { type: 'user',
       id: '59ca900e01dc2e62528f13f8',
       user_id: '187',
       anonymous: false,
       email: '[email protected]',
       phone: null,
       .... (full user object) ...
       custom_attributes: [Object] },
     { type: 'user',
       id: '5a03e2d33e69b29660557c9f',
       user_id: '0',
       anonymous: false,
       .... (full user object) ...
 ],
  total_count: 3 
  }