> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/management-and-administration/integrations/heap.md).

# Heap

### Harness FME + Heap <a href="#harness-fme-heap" id="harness-fme-heap"></a>

FME impressions describe the treatment that each user receives when a feature flag is evaluated. Attach flag names and treatments as Heap events properties for a user's session.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

To connect Heap to Harness FME, you need the following,

* FME JavaScript SDK evaluating feature flag treatments' client side
* Heap’s Web JavaScript snippet

### How to use <a href="#how-to-use" id="how-to-use"></a>

The following explains how to use Heap.

#### Implement both libraries <a href="#implement-both-libraries" id="implement-both-libraries"></a>

The code below implements both Harness FME and Heap's JavaScript libraries, assuming both libraries are loaded in the header section. In this example, the Harness FME SDK is wrapped with the class SplitIO. Be sure sure to update the key and authorizationKey fields in the factory initialization.

FME feature flag treatments are calculated for a list of feature flag names defined in an array variable splitNames. Be sure to update the array with the correct flag names.

#### Evaluate treatments <a href="#evaluate-treatments" id="evaluate-treatments"></a>

Once the treatments are fetched, the script uses `heap.addEventProperties` to add the feature flag names as a property name and the respective treatments as the value.

#### Add a prefix <a href="#add-a-prefix" id="add-a-prefix"></a>

A prefix of `Split.` is added to each feature flag name in the below example to make it easier to filter in Heap.

#### Verify FME feature flag treatments as Heap event properties <a href="#verify-fme-feature-flag-treatments-as-heap-event-properties" id="verify-fme-feature-flag-treatments-as-heap-event-properties"></a>

Click a pageview event and view event properties.

![](/files/2jM8LIKjrzE0JRXx3UL4)

#### Analyze Heap data by FME feature flag treatments <a href="#analyze-heap-data-by-fme-feature-flag-treatments" id="analyze-heap-data-by-fme-feature-flag-treatments"></a>

Create a graph of the count of page views filtering by Harness FME feature flag names and treatments. Group by the flag name to see the count by treatment.

![](/files/NEY9PnyjYbLx9sEMk5JE)

### Code <a href="#code" id="code"></a>

The source code referenced above can be found below:

```
<script>
userId="bob";
heap.identify(userId);
class SplitIO {
    constructor() {
        this.isSDKReady=false;
        this.factory = splitio({
            core: {
                authorizationKey: 'BROWSER API KEY',
                key: userId,
            },
            storage: {
            type: 'LOCALSTORAGE'
            },
        });
        this.client = this.factory.client();
        this.client.on(this.client.Event.SDK_READY, () => {
            this.isSDKReady=true;
        });
    }
    applyFeatureFlags(featureNames) {
        return this.client.getTreatments(featureNames);
    }
    destroySplit() {
        this.client.destroy();
        this.client=null;
    }
}

function calculateTreatments() {
    splitNames=["sample_feature", "show_coupon", "enable_search"];
    treatments = mySplit.applyFeatureFlags(splitNames);

    var split_treatments ={};
    for (var i = 0; i < splitNames.length; i++) {
        console.log(splitNames[i]+": "+treatments[splitNames[i]]);
        split_treatments["Split."+splitNames[i]] = treatments[splitNames[i]];
    }
    heap.addEventProperties(split_treatments);
}

var mySplit = new SplitIO();
if (!mySplit.isSDKReady) {
    console.log("Split not ready yet");
    mySplit.client.on(mySplit.client.Event.SDK_READY, () => {
        calculateTreatments();
    });
} else {
    calculateTreatments();
}
</script>
```

### About this integration <a href="#about-this-integration" id="about-this-integration"></a>

This is a third-party integration that has been tested by the Harness FME team. Harness does not own or maintain this integration. For more information, reach out to the [contributor](mailto:bilal@split.io.).

If you’d like a demo of Harness FME, or help to implement any of our integrations, contact [support@split.io](mailto:support@#split.io).
