# Heap (v1)

Information note **Heap extraction is supported by Stitch**   
This integration is powered by [Singer's](https://www.singer.io/) Heap tap and certified by Stitch. [Check out and contribute to the repo on GitHub](https://github.com/singer-io/tap-heap).  
  
For support, contact [Support](https://community.qlik.com/t5/Support/ct-p/qlikSupport).

## Heap integration summary

Stitch’s Heap integration replicates data from Avro files published to Amazon S3 via Heap’s **Connect** for Amazon S3 feature. Refer to the [Schema](https://help.qlik.com/en-US/stitch/integrations/saas/heap#schema) section for a list of objects available for replication.

## Heap feature snapshot

A high-level look at Stitch's Heap (v1) integration, including release status, useful links, and the features supported in Stitch.

| **STITCH** |  |  |  |
| --- | --- | --- | --- |
| **[Release status](https://help.qlik.com/en-US/stitch/integrations/identify-an-integration-version)** | Released on February 13, 2019 | **Supported by**<br><br>the Info icon<br><br>Indicates if the integration is supported by Stitch or the Singer community. | [Stitch](https://community.qlik.com/t5/Support/ct-p/qlikSupport) |
| **Stitch plan**<br><br>the Info icon<br><br>The type of Stitch plan required to use the integration. | Standard | **[API availability](https://help.qlik.com/en-US/stitch/developers/stitch-connect/guides/source-destination-reference)**<br><br>the Info icon<br><br>Indicates if the integration is available as a source in Stitch Connect. | the Success icon<br><br>This version of the integration is available via the API.<br><br><br>Available |
| **Singer GitHub repository** | [singer-io/tap-heap](https://github.com/singer-io/tap-heap) |  |  |
| **REPLICATION SETTINGS** |  |  |  |
| **[Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/anchor-scheduling)**<br><br>the Info icon<br><br>A type of replication scheduling where an integration's Replication Frequency is anchored to a time you select. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **[Advanced Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/advanced-scheduling)**<br><br>the Info icon<br><br>A type of replication scheduling that allows you to specify granular start times for data extraction using cron expressions. | the Remove icon<br><br>Advanced Scheduling is not supported for this integration.<br><br><br>Unsupported |
| **Table-level reset**<br><br>the Info icon<br><br>Indicates if data can be reset at the table level. If unsupported, data can only be reset at the integration level. | the Remove icon<br><br>Table-level resets are not supported for this integration. Resets are only supported at the integration level.<br><br><br>Unsupported | **[Configurable Replication Methods](https://help.qlik.com/en-US/stitch/replication/replication-methods)**<br><br>the Info icon<br><br>Indicates if Replication Methods can be defined by you for tables in the integration. | the Remove icon<br><br>Configurable Replication Methods are not supported for this integration. Stitch will use pre-defined replication methods for tables you set to replicate.<br><br><br>Unsupported |
| **DATA SELECTION** |  |  |  |
| **Table selection**<br><br>the Info icon<br><br>The ability to select individual tables for replication in the Stitch interface. If table selection is unavailable, all tables and all the columns they contain will be set to replicate by default. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **Column selection**<br><br>the Info icon<br><br>The ability to select individual columns for replication in the Stitch interface. If column selection is unavailable, all columns will be set to replicate by default. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported |
| **Select all**<br><br>the Info icon<br><br>Indicates if the integration supports selecting all available tables and columns. | the Success icon<br><br>Supported<br><br><br>Supported |  |  |
| **TRANSPARENCY** |  |  |  |
| **[Extraction Logs](https://help.qlik.com/en-US/stitch/replication/extractions/integration-extraction-logs)**<br><br>the Info icon<br><br>Logs detailing the Extraction phase of the replication process for a given integration. Includes error info, should an error occur. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported | **[Loading Reports](https://help.qlik.com/en-US/stitch/replication/integration-loading-reports)**<br><br>the Info icon<br><br>Reports detailing the Loading phase of the replication process for a given integration. Includes the number of rows loaded for each table and error info, should an error occur. | the Success icon<br><br>This feature is supported for this version of the integration.<br><br><br>Supported |

## Connecting Heap

### Heap setup requirements

To set up Heap in Stitch, you need:

* **Access to Heap Connect using Amazon S3**. Stitch’s Heap integration currently only replicates data from Heap Amazon S3 instances.

* **Permissions in AWS Identity Access Management (IAM) that allow you to create policies, create roles, and attach policies to roles**. This is required to grant Stitch authorization to your S3 bucket.

### Step 1: Retrieve your Amazon Web Services account ID

1. Sign into your Amazon Web Services (AWS) account.

2. Click the **user menu**, located between the **bell** and **Global** menus in the top-right corner of the page.

3. Click **My Account**.

4. In the **Account Settings** section of the page, locate the **Account Id** field:

   ![An AWS account ID, highlighted in the AWS Account Settings page](https://help.qlik.com/en-US/stitch/images/integrations/s3-csv-account-id.png)An AWS account ID, highlighted in the AWS Account Settings pageAn AWS account ID, highlighted in the AWS Account Settings page

Keep this handy - you’ll need it to complete the setup.

### Step 2: Add Heap as a Stitch data source

1. [Sign into your Stitch account](https://app.stitchdata.com/).

2. On the Stitch Dashboard page, click the **Add Integration** button.

3. Click the **Heap** icon.

4. Enter a name for the integration. This is the name that will display on the Stitch Dashboard for the integration; it’ll also be used to create the schema in your destination.

   For example, the name “Stitch Heap” would create a schema called `stitch_heap` in the destination. **Note**: Schema names cannot be changed after you save the integration.

5. In the **S3 Bucket** field, enter the name of the bucket. Enter only the bucket name: No URLs, `https`, or S3 parts. For example: `heap-rs3-stitch-bucket`

6. In the **AWS Account ID** field, paste the account ID you retrieve in [Step 1](https://help.qlik.com/en-US/stitch/integrations/saas/heap#retrieve-aws-account-id).

### Step 3: Define the historical replication start date

The Sync Historical Data setting defines the starting date for your Heap integration. This means that data **equal to or newer than this date** will be replicated to your data warehouse.

Change this setting if you want to replicate data beyond Heap’s default setting of **1 year**. For a detailed look at historical replication jobs, check out the [Syncing Historical SaaS Data](https://help.qlik.com/en-US/stitch/replication/syncing-historical-saas-data-resetting-replication-keys) guide.

### Step 4: Create a replication schedule

Information note Replication schedules affect the time Extraction begins, not the time to data loaded. Refer to the [Replication Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling) documentation for more information.

In the **Replication Frequency** section, you’ll create the integration’s [replication schedule](https://help.qlik.com/en-US/stitch/replication/replication-scheduling). An integration’s replication schedule determines how often Stitch runs a replication job, and the time that job begins.

Heap integrations support the following replication scheduling methods:

* [Replication Frequency](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/replication-frequency)

* [Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling/anchor-scheduling)

To keep your row usage low, consider setting the integration to replicate less frequently. See the [Understanding and Reducing Your Row Usage guide](https://help.qlik.com/en-US/stitch/getting-started/understanding-stitch-usage) for tips on reducing your usage.

### Step 5: Grant access to your bucket using AWS IAM

Information note **Note**: To complete this step, you must have permissions in AWS Identity Access Management (IAM) that allow you to create/modify IAM policies and roles.

Next, Stitch will display a **Configure Your Heap Integration** page. This page contains the info you need to configure bucket access for Stitch, which is accomplished via an IAM policy and role.

**Note**: Saving the integration before you’ve completed the steps below will result in connection errors.

* [Step 5.1: Create an IAM policy](https://help.qlik.com/en-US/stitch/integrations/saas/heap#create-iam-policy)

* [Step 5.2: Create an IAM role for Stitch](https://help.qlik.com/en-US/stitch/integrations/saas/heap#create-stitch-iam-role)

* [Step 5.3: Check and save the connection in Stitch](https://help.qlik.com/en-US/stitch/integrations/saas/heap#check-save-stitch-connection)

#### Step 5.1: Create an IAM policy

[An IAM policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json) is JSON-based access policy language to manage permissions to Heap resources.

For more info about the permissions the auto-generated policy Stitch IAM policy grants, click the link below.

Heap permissions

| **Permission name** | **Operation** | **Description** |
| --- | --- | --- |
| **s3:GetObject** | **[GET Object](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html)** | Allows for the retrieval of objects from Amazon S3. |
| **[HEAD Object](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html)** | Allows for the retrieval of metadata from an object without returning the object itself. |  |
| **s3:ListBucket** | **[GET Bucket (List Objects)](http://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html)** | Allows for the return of some or all (up to 1,000) of the objects in a bucket. |
| **[HEAD Bucket](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html)** | Used to determine if a bucket exists and access is allowed. |  |

To create the IAM policy:

1. In AWS, [navigate to the IAM service](https://console.aws.amazon.com/iam/home#/home) by clicking the **Services** menu and typing **IAM**.
2. Click **IAM** once it displays in the results.
3. On the IAM home page, click **Policies** in the menu on the left side of the page.
4. Click **Create Policy**.
5. In the **Create Policy** page, click the **JSON** tab.
6. Select everything currently in the text field and delete it.
7. In the text field, paste the IAM policy from the **Configure Your Heap Integration** page in Stitch.
8. Click **Review policy**.
9. On the **Review Policy** page, give the policy a name. For example: `stitch_heap`
10. Click **Create policy**.

#### Step 5.2: Create an IAM role for Stitch

Information note

**Required permissions**

To complete this step, you need the following AWS IAM permissions: `CreateRole` and `AttachRolePolicy`. Refer to [Amazon’s documentation](https://docs.aws.amazon.com/IAM/latest/APIReference/API_Operations.html) for more info.

the Info icon

**Roles can’t be used for multiple integrations**

If you’re creating multiple Heap integrations, you’ll need to complete this step for each integration you’re connecting.

The **Role Name** Stitch uses to connect to the Amazon resource is unique to the integration. Attempting to re-use a role for multiple integrations will cause connection errors.

In this step, you’ll create an IAM role for Stitch and apply the IAM policy from the previous step. This will ensure that Stitch is visible in any logs and audits.

To create the role, you’ll need the **Account ID**, **External ID**, and **Role Name** values provided on the Stitch **Configure Your Heap Integration** page.

1. In AWS, navigate to the [IAM Roles](https://console.aws.amazon.com/iam/home#/roles) page.
2. Click **Create Role**.
3. On the **Create Role** page:
   1. In the **Select type of trusted entity** section, click the **Another AWS account** option.
   2. In the **Account ID** field, paste the Account ID from Stitch. **Note**: This isn’t your AWS account ID from Step 1 - this is the Account ID that displays in Stitch on the **Configure Your Heap Integration** page.
   3. In the **Options** section, check the **Require external ID** box.
   4. In the **External ID** field that displays, paste the External ID from the Stitch **Configure Your Heap Integration** page: ![Account ID and External ID fields mapped from Stitch to AWS](https://help.qlik.com/en-US/stitch/images/integrations/aws-account-external-ids.png)Account ID and External ID fields mapped from Stitch to AWSAccount ID and External ID fields mapped from Stitch to AWS
   5. Click **Next: Permissions**.
4. On the **Attach permissions** page:
   1. Search for the policy you created in the [previous step](https://help.qlik.com/en-US/stitch/integrations/saas/heap#create-iam-policy).
   2. Once located, check the box next to it in the table.
   3. Click **Next: Tags**.
5. If you want to enter any tags, do so on the **Add tags** page. Otherwise, click **Next: Review**.
6. On the **Review** page:
   1. In the **Role name** field, paste the Role Name from the Stitch **Configure Your Heap Integration** page: ![Role name field mapped from Stitch to AWS](https://help.qlik.com/en-US/stitch/images/integrations/aws-role-name.png)Role name field mapped from Stitch to AWSRole name field mapped from Stitch to AWS

      **Remember**: Role names are unique to the Stitch Heap integration they’re created for. Attempting to use the same role for multiple integrations will cause connection errors.

   2. Enter a description in the **Role description** field. For example: `Stitch role for Heap integration.`

   3. Click **Create role**.

#### Step 5.3: Check and save the connection in Stitch

Information note **Note**: Saving the integration before you’ve completed the IAM policy and role steps will result in connection errors.

After you’ve created the IAM policy and role, you can save the integration in Stitch. When finished, click **Check and Save**.

### Step 6: Set objects to replicate

Information note **Is an object missing or not replicating?** Verify that the object meets the requirements for [selection](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#selection-requirements) and [replication](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#replication-requirements).

The last step is to select the tables and columns you want to replicate. [Learn about the available tables for this integration.](https://help.qlik.com/en-US/stitch/integrations/saas/heap#schema)

**Note**: If a replication job is currently in progress, new selections won’t be used until the next job starts.

* Selection options
* Individual tables and columns
* All tables and columns

For Heap integrations, you can select:

1. **Individual tables and columns**

2. **All tables and columns**

Click the tabs to view instructions for each selection method.

1. In the integration’s **Tables to Replicate tab**, locate a table you want to replicate.

2. To track a table, click the **checkbox** next to the table’s name. A blue checkmark means the table is set to replicate.

3. To track a column, click the **checkbox** next to the column’s name. A blue checkmark means the column is set to replicate.

4. Repeat this process for all the tables and columns you want to replicate.

5. When finished, click the **Finalize Your Selections** button at the bottom of the screen to save your selections.

Information note **Important**: Using the **Select All** feature will overwrite any previous selections. However, selections aren’t final until **Finalize Your Selections** is clicked. Clicking **Cancel** will restore your previous selections. Refer to the [Select All guide](https://help.qlik.com/en-US/stitch/replication/extractions/data-selection/setting-tables-and-columns-to-replicate#set-all-data-to-replicate) for more info about this feature.

1. Click into the integration from the Stitch Dashboard page.

2. Click the **Tables to Replicate** tab.

3. In the list of tables, click the box next to the **Table Names** column.

4. In the menu that displays, click **Track all Tables and Fields**:

   ![The Track all Tables and Fields menu in the Tables to Replicate tab](https://help.qlik.com/en-US/stitch/images/replication/select-all-tables-menu.png)The Track all Tables and Fields menu in the Tables to Replicate tabThe Track all Tables and Fields menu in the Tables to Replicate tab

5. Click the **Finalize Your Selections** button at the bottom of the page to save your data selections.

### Initial and historical replication jobs

After you finish setting up Heap, its **Sync Status** may show as **Pending** on either the Stitch Dashboard or in the Integration Details page.

For a new integration, a **Pending** status indicates that Stitch is in the process of scheduling the initial replication job for the integration. **This may take some time to complete.**

Information note

**Initial replication jobs with Anchor Scheduling**

If using Anchor Scheduling, an initial replication job may not kick off immediately. This depends on the selected Replication Frequency and Anchor Time. Refer to the [Anchor Scheduling](https://help.qlik.com/en-US/stitch/replication/replication-scheduling#job-scheduling-and-anchor-times) documentation for more information.

#### Free historical data loads

The first seven days of replication, beginning when data is first replicated, are free. Rows replicated from the new integration during this time won’t count towards your quota. Stitch offers this as a way of testing new integrations, measuring usage, and ensuring historical data volumes don’t quickly consume your quota.

Information note **Replication will continue after the seven days are over**. If you’re no longer interested in this source, be sure to **pause** or **delete** the integration to prevent unwanted usage.

## Heap replication

Replication in Stitch’s Heap integration depends on two factors:

1. [How Heap syncs data to your Amazon S3 bucket](https://help.qlik.com/en-US/stitch/integrations/saas/heap#heap-data-syncs-to-amazon-s3), and
2. [How Stitch identifies new data in Heap integrations](https://help.qlik.com/en-US/stitch/integrations/saas/heap#incremental-replication-for-heap)

#### Heap data syncs to Amazon S3

Heap dumps data into Amazon S3 periodically. [By default, this is on a nightly basis](https://help.heap.io/integrations/data-warehouses/s3/#process-overview).

According to Heap’s documentation:

> Heap will provide a periodic dump of data into S3 (nightly by default). Data will be delivered in the form of Avro-encoded files, each of which corresponds to one downstream table (though there can be multiple files per table). Dumps will be incremental, though individual table dumps can be full resyncs, depending on whether the table was recently toggled or the event definition modified.

This means that while files will only include new and updated data pertinent to that specific object (table), a full resync may be included.

#### Key-based Incremental Replication using file modification timestamps

To identify new and updated data for replication, Stitch will use file modification timestamps as [Replication Keys](https://help.qlik.com/en-US/stitch/replication/replication-keys) and store them on a per-table basis. This means that only files dumped from a new Heap data sync will be selected for replication.

While data from Heap integrations is replicated using [Key-based Incremental Replication](https://help.qlik.com/en-US/stitch/replication/replication-methods/key-based-incremental), the behavior for this integration differs subtly from other integrations.

The table below compares Key-based Incremental Replication and [Replication Key](https://help.qlik.com/en-US/stitch/replication/replication-keys) behavior for Heap to that of other integrations.

|  | **Heap** | **Other integrations** |
| --- | --- | --- |
| **What's replicated during a replication job?** | The entire contents of a modified file. | Only new or updated rows in a table. |
| **What's used as a Replication Key?** | The time a file is modified. | A column or columns in a table. |
| **Are Replication Keys inclusive?** | **No**. Only files with a modification timestamp value greater than the last saved bookmark are replicated. | **Yes**. Rows with a Replication Key value **greater than or equal to** the last saved bookmark are replicated. |

## Heap table reference

Information note

**Schemas and versioning**

Schemas and naming conventions can change from version to version, so we recommend verifying your integration’s version before continuing.

The schema and info displayed below is for **version 1** of this integration.

This is the latest version of the Heap integration.

### Custom attributes

Heap’s data model is dynamic, meaning it changes as custom attributes are added to object types in your account. For example: Adding new user attributes to the [`user`](https://help.qlik.com/en-US/stitch/integrations/saas/heap#users) object.

This means that the Heap schema in your destination may also change over time as you add new attributes in Heap.

When a new attribute is added to an object in Heap, it will display as a selectable field in the Stitch app. **Note**: To include the field in replication, you’ll need to select it in Stitch. Stitch will not automatically select new fields.

The schema documentation following this section outlines the default attributes for each object type according to [Heap’s documentation](https://help.qlik.com/en-US/stitch/integrations/saas/heap).

### Event tables

For each event type you define in Heap, a table for that event will be available for selection in Stitch.

For example: If there’s a `Sign up - Click button` event, there will be a table named `sign_up_click_button`.

Refer to the [`[event_type]`](https://help.qlik.com/en-US/stitch/integrations/saas/heap#event_type) schema documentation for a list of default event attributes.

**Note**: When new event types are added in Heap, you will need to select the table and fields in Stitch to include it in replication.

Information note

**Table and column names in your destination**

Depending on your destination, table and column names may not appear as they are outlined below.

For example: Object names are lowercased in Redshift (`CusTomERs` &gt; `customers`), while case is maintained in PostgreSQL destinations (`CusTomERs` &gt; `CusTomERs`). Refer to the [Loading Guide](https://help.qlik.com/en-US/stitch/replication/loading/destination-guides) for your destination for more info.

### event\_tables

For every event type defined in Heap, a table will display in the Stitch app. The name of the table will be the event name, which Heap will first strip the non-alphanumeric characters from. For example: The table name for `Sign Up - Click Link` will be transformed into `sign_up_click_link` by Heap.

**Note**: Custom attributes are supported for this table. As Heap schemas are dynamic, Stitch’s `event_tables` documentation will only list the non-custom attributes outlined in Heap’s documentation.

| **Replication Method [](https://help.qlik.com/en-US/stitch/replication/replication-methods)[the Info icon](https://help.qlik.com/en-US/stitch/replication/replication-methods)[](https://help.qlik.com/en-US/stitch/replication/replication-methods)** | Key-based Incremental |
| --- | --- |
| **Primary Key ![](https://help.qlik.com/en-US/stitch/images/replication/primary-key-icon.svg)** | event\_id |
| **Useful links** | [Heap documentation](https://help.heap.io/heap-connect/heap-connect-guide/data-schema/#event-tables "Opens in new tab: Heap documentation") |

event\_tables table foreign keys

| Join event\_tables with | on |
| --- | --- |
| [pageviews](https://help.qlik.com/en-US/stitch/integrations/saas/heap#pageviews) | ```<br>event_tables.event_id = pageviews.event_id<br>```<br><br>```<br>event_tables.session_id = pageviews.session_id<br>```<br><br>```<br>event_tables.user_id = pageviews.user_id<br>``` |
| [sessions](https://help.qlik.com/en-US/stitch/integrations/saas/heap#sessions) | ```<br>event_tables.event_id = sessions.event_id<br>```<br><br>```<br>event_tables.session_id = sessions.session_id<br>```<br><br>```<br>event_tables.user_id = sessions.user_id<br>``` |
| [user_migrations](https://help.qlik.com/en-US/stitch/integrations/saas/heap#user-migrations) | ```<br>event_tables.user_id = user_migrations.to_user_id<br>``` |
| [users](https://help.qlik.com/en-US/stitch/integrations/saas/heap#users) | ```<br>event_tables.user_id = users.user_id<br>``` |

event\_tables table schema

| **IP**<br><br><br>STRING |
| --- |
| **action\_method**<br><br><br>STRING |
| **app\_name**<br><br><br>STRING |
| **app\_version**<br><br><br>STRING |
| **browser**<br><br><br>STRING |
| **carrier**<br><br><br>STRING |
| **city**<br><br><br>STRING |
| **country**<br><br><br>STRING |
| **device**<br><br><br>STRING |
| **device\_type**<br><br><br>STRING |
| **event\_id**<br><br><br>STRING |
| **hash**<br><br><br>STRING |
| **href**<br><br><br>STRING |
| **landing\_page**<br><br><br>STRING |
| **library**<br><br><br>STRING |
| **path**<br><br><br>STRING |
| **platform**<br><br><br>STRING |
| **query**<br><br><br>STRING |
| **referrer**<br><br><br>STRING |
| **region**<br><br><br>STRING |
| **screen\_ally\_id**<br><br><br>STRING |
| **screen\_ally\_label**<br><br><br>STRING |
| **search\_keyword**<br><br><br>STRING |
| **session\_id**<br><br><br>INTEGER |
| **session\_time**<br><br><br>STRING |
| **target\_ally\_id**<br><br><br>STRING |
| **target\_ally\_label**<br><br><br>STRING |
| **target\_text**<br><br><br>STRING |
| **target\_view\_class**<br><br><br>STRING |
| **target\_view\_name**<br><br><br>STRING |
| **time**<br><br><br>STRING |
| **title**<br><br><br>STRING |
| **type**<br><br><br>STRING |
| **user\_id**<br><br><br>INTEGER |
| **utm\_campaign**<br><br><br>STRING |
| **utm\_content**<br><br><br>STRING |
| **utm\_medium**<br><br><br>STRING |
| **utm\_source**<br><br><br>STRING |
| **utm\_term**<br><br><br>STRING |
| **view\_controller**<br><br><br>STRING |

### pageviews

The `pageviews` table contains info about pageviews.

**Note**: Custom attributes are supported for this table. As Heap schemas are dynamic, Stitch’s `pageviews` documentation will only list the non-custom attributes outlined in Heap’s documentation.

| **Replication Method [](https://help.qlik.com/en-US/stitch/replication/replication-methods)[the Info icon](https://help.qlik.com/en-US/stitch/replication/replication-methods)[](https://help.qlik.com/en-US/stitch/replication/replication-methods)** | Key-based Incremental |
| --- | --- |
| **Primary Key ![](https://help.qlik.com/en-US/stitch/images/replication/primary-key-icon.svg)** | event\_id |
| **Useful links** | [Heap documentation](https://help.heap.io/heap-connect/heap-connect-guide/data-schema/#pageviews-table "Opens in new tab: Heap documentation") |

pageviews table foreign keys

| Join pageviews with | on |
| --- | --- |
| [event_tables](https://help.qlik.com/en-US/stitch/integrations/saas/heap#event-tables) | ```<br>pageviews.event_id = event_tables.event_id<br>```<br><br>```<br>pageviews.session_id = event_tables.session_id<br>```<br><br>```<br>pageviews.user_id = event_tables.user_id<br>``` |
| [sessions](https://help.qlik.com/en-US/stitch/integrations/saas/heap#sessions) | ```<br>pageviews.event_id = sessions.event_id<br>```<br><br>```<br>pageviews.session_id = sessions.session_id<br>```<br><br>```<br>pageviews.user_id = sessions.user_id<br>``` |
| [user_migrations](https://help.qlik.com/en-US/stitch/integrations/saas/heap#user-migrations) | ```<br>pageviews.user_id = user_migrations.to_user_id<br>``` |
| [users](https://help.qlik.com/en-US/stitch/integrations/saas/heap#users) | ```<br>pageviews.user_id = users.user_id<br>``` |

pageviews table schema

| **IP**<br><br><br>STRING |
| --- |
| **app\_name**<br><br><br>STRING |
| **app\_version**<br><br><br>STRING |
| **browser**<br><br><br>STRING |
| **carrier**<br><br><br>STRING |
| **city**<br><br><br>STRING |
| **country**<br><br><br>STRING |
| **device**<br><br><br>STRING |
| **device\_type**<br><br><br>STRING |
| **event\_id**<br><br><br>STRING |
| **hash**<br><br><br>STRING |
| **landing\_page**<br><br><br>STRING |
| **library**<br><br><br>STRING |
| **path**<br><br><br>STRING |
| **platform**<br><br><br>STRING |
| **query**<br><br><br>STRING |
| **referrer**<br><br><br>STRING |
| **region**<br><br><br>STRING |
| **screen\_ally\_id**<br><br><br>STRING |
| **screen\_ally\_label**<br><br><br>STRING |
| **search\_keyword**<br><br><br>STRING |
| **session\_id**<br><br><br>INTEGER |
| **session\_time**<br><br><br>STRING |
| **time**<br><br><br>STRING |
| **title**<br><br><br>STRING |
| **user\_id**<br><br><br>INTEGER |
| **utm\_campaign**<br><br><br>STRING |
| **utm\_content**<br><br><br>STRING |
| **utm\_medium**<br><br><br>STRING |
| **utm\_source**<br><br><br>STRING |
| **utm\_term**<br><br><br>STRING |
| **view\_controller**<br><br><br>STRING |

### sessions

The `sessions` table contains info about sessions. In Heap, a web session ends after 30 minutes of user inactivity, while in iOS, a session ends after the app has entered the background.

**Note**: Custom attributes are supported for this table. As Heap schemas are dynamic, Stitch’s `sessions` documentation will only list the non-custom attributes outlined in Heap’s documentation.

| **Replication Method [](https://help.qlik.com/en-US/stitch/replication/replication-methods)[the Info icon](https://help.qlik.com/en-US/stitch/replication/replication-methods)[](https://help.qlik.com/en-US/stitch/replication/replication-methods)** | Key-based Incremental |
| --- | --- |
| **Primary Key ![](https://help.qlik.com/en-US/stitch/images/replication/primary-key-icon.svg)** | event\_id |
| **Useful links** | [Heap documentation](https://help.heap.io/heap-connect/heap-connect-guide/data-schema/#sessions-table "Opens in new tab: Heap documentation") |

sessions table foreign keys

| Join sessions with | on |
| --- | --- |
| [event_tables](https://help.qlik.com/en-US/stitch/integrations/saas/heap#event-tables) | ```<br>sessions.event_id = event_tables.event_id<br>```<br><br>```<br>sessions.session_id = event_tables.session_id<br>```<br><br>```<br>sessions.user_id = event_tables.user_id<br>``` |
| [pageviews](https://help.qlik.com/en-US/stitch/integrations/saas/heap#pageviews) | ```<br>sessions.event_id = pageviews.event_id<br>```<br><br>```<br>sessions.session_id = pageviews.session_id<br>```<br><br>```<br>sessions.user_id = pageviews.user_id<br>``` |
| [user_migrations](https://help.qlik.com/en-US/stitch/integrations/saas/heap#user-migrations) | ```<br>sessions.user_id = user_migrations.to_user_id<br>``` |
| [users](https://help.qlik.com/en-US/stitch/integrations/saas/heap#users) | ```<br>sessions.user_id = users.user_id<br>``` |

sessions table schema

| **IP**<br><br><br>STRING |
| --- |
| **app\_name**<br><br><br>STRING |
| **app\_version**<br><br><br>STRING |
| **browser**<br><br><br>STRING |
| **carrier**<br><br><br>STRING |
| **city**<br><br><br>STRING |
| **country**<br><br><br>STRING |
| **device**<br><br><br>STRING |
| **device\_type**<br><br><br>STRING |
| **event\_id**<br><br><br>STRING |
| **landing\_page**<br><br><br>STRING |
| **library**<br><br><br>STRING |
| **platform**<br><br><br>STRING |
| **referrer**<br><br><br>STRING |
| **region**<br><br><br>STRING |
| **search\_keyword**<br><br><br>STRING |
| **session\_id**<br><br><br>INTEGER |
| **time**<br><br><br>STRING |
| **user\_id**<br><br><br>INTEGER |
| **utm\_campaign**<br><br><br>STRING |
| **utm\_content**<br><br><br>STRING |
| **utm\_medium**<br><br><br>STRING |
| **utm\_source**<br><br><br>STRING |
| **utm\_term**<br><br><br>STRING |

### user\_migrations

The `user_migrations` table contains info about user migrations.

**Note**: Custom attributes are supported for this table. As Heap schemas are dynamic, Stitch’s `user_migrations` documentation will only list the non-custom attributes outlined in Heap’s documentation.

| **Replication Method [](https://help.qlik.com/en-US/stitch/replication/replication-methods)[the Info icon](https://help.qlik.com/en-US/stitch/replication/replication-methods)[](https://help.qlik.com/en-US/stitch/replication/replication-methods)** | Key-based Incremental |
| --- | --- |
| **Primary Key ![](https://help.qlik.com/en-US/stitch/images/replication/primary-key-icon.svg)** | from\_user\_id |
| **Useful links** | [Heap documentation](https://help.heap.io/heap-connect/heap-connect-guide/data-schema/#user-migrations-table "Opens in new tab: Heap documentation") |

user\_migrations table foreign keys

| Join user\_migrations with | on |
| --- | --- |
| [event_tables](https://help.qlik.com/en-US/stitch/integrations/saas/heap#event-tables) | ```<br>user_migrations.to_user_id = event_tables.user_id<br>``` |
| [pageviews](https://help.qlik.com/en-US/stitch/integrations/saas/heap#pageviews) | ```<br>user_migrations.to_user_id = pageviews.user_id<br>``` |
| [sessions](https://help.qlik.com/en-US/stitch/integrations/saas/heap#sessions) | ```<br>user_migrations.to_user_id = sessions.user_id<br>``` |
| [users](https://help.qlik.com/en-US/stitch/integrations/saas/heap#users) | ```<br>user_migrations.to_user_id = users.user_id<br>``` |

user\_migrations table schema

| **from\_user\_id**<br><br><br>STRING |
| --- |
| **time**<br><br><br>STRING |
| **to\_user\_id**<br><br><br>INTEGER |

### users

The `users` table contains info about users.

**Note**: Custom attributes are supported for this table. As Heap schemas are dynamic, Stitch’s `users` documentation will only list the non-custom attributes outlined in Heap’s documentation.

| **Replication Method [](https://help.qlik.com/en-US/stitch/replication/replication-methods)[the Info icon](https://help.qlik.com/en-US/stitch/replication/replication-methods)[](https://help.qlik.com/en-US/stitch/replication/replication-methods)** | Key-based Incremental |
| --- | --- |
| **Primary Key ![](https://help.qlik.com/en-US/stitch/images/replication/primary-key-icon.svg)** | user\_id |
| **Useful links** | [Heap documentation](https://help.heap.io/heap-connect/heap-connect-guide/data-schema/#users-table "Opens in new tab: Heap documentation") |

users table foreign keys

| Join users with | on |
| --- | --- |
| [event_tables](https://help.qlik.com/en-US/stitch/integrations/saas/heap#event-tables) | ```<br>users.user_id = event_tables.user_id<br>``` |
| [pageviews](https://help.qlik.com/en-US/stitch/integrations/saas/heap#pageviews) | ```<br>users.user_id = pageviews.user_id<br>``` |
| [sessions](https://help.qlik.com/en-US/stitch/integrations/saas/heap#sessions) | ```<br>users.user_id = sessions.user_id<br>``` |
| [user_migrations](https://help.qlik.com/en-US/stitch/integrations/saas/heap#user-migrations) | ```<br>users.user_id = user_migrations.to_user_id<br>``` |

users table schema

| **email**<br><br><br>STRING |
| --- |
| **handle**<br><br><br>STRING |
| **identity**<br><br><br>STRING |
| **joindate**<br><br><br>STRING |
| **last\_modified**<br><br><br>STRING |
| **user\_id**<br><br><br>STRING |