Heap Destination

On this page

Heap automatically captures every user interaction with no extra code. This includes clicks, taps, gestures, form submissions, page views, and more. The Heap Destination is open-source. You can browse the code on GitHub.

This document was last updated on January 29, 2018. If you notice any gaps, out-dated 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 Heap 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-mode
☁️ Cloud-mode
  1. From your Segment UI’s Destinations page click on “Add Destination”.
  2. Search for “Heap” within the Destinations Catalog and confirm the Source you’d like to connect to.
  3. Drop in your Heap “App ID” into the connection settings.
  4. If you are using Heap via Segment’s client-side analytics.js library, we asynchronously load Heap’s Javascript library onto the page. As such, all native functionality of Heap, including auto-capturing of all events.


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


When you call identify we call Heap’s identify method with the userId and traits you provide.

If one of your traits is of the date property type, we will convert it into an ISO string.


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:

analytics.track('Clicked Button');

When you call track from analytics.js, we call Heap’s track function with exactly the same parameters. Calling track from one of our mobile SDKs or server-side sources records a Heap Custom Event with the same event name and properties.

If one of your properties is of the date property type, we will convert it into an ISO string.


Anonymous traffic not showing up from server-side source

Ensure that you are specifying a user_id in your event calls. The Heap API will reject any server-side events without a user_id.

Nested Objects and Arrays

Heap does not accept nested properties, so we will flatten and stringify them before sending to Heap. For example:

 analytics.track('Signed Up', {
   foo: {
     bar: {
       cheese: 'american',
       prop: [1, 2, 3],
       products: [{"A": "Jello"}, {"B": "Peanut"}]

The properties would be sent as:

foo.bar.cheese: 'american'
foo.bar.prop: '[1,2,3]'
foo.bar.products: "[{'A': 'Jello'},{'B': 'Peanut'}]"


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.


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

App ID

You can find the snippet containing your app ID in Heap’s QuickStart docs. It’s inside the heap.load('YOUR_APP_ID') function call.

This page was last modified: 21 Nov 2019

Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
Create free account