Search code examples
intercom

Track events for leads Intercom


How i can track events for leads with JavaScript API. In documentation talks like:

When using the JavaScript API, adding the code to your app makes the Events API available. Once added, you can submit an event using the trackEvent method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.

But. It doesn't work. When I track event, intercom create new user. Not submit event for lead.

In Intercom admin panel lead was created before.


Solution

  • This is not documented in their API docs, but instead of passing in the email parameter you use anonymous_email instead and Intercom creates it as a Lead.

    To simply create a lead, for example, you would do:

    Intercom('update', {
      "anonymous_email": email,
      "name": name
    });