> For the complete documentation index, see [llms.txt](https://docs.peakcommerce.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peakcommerce.com/integrations/analytics-and-data/heap-analytics/integrating-heap-analytics-with-peakcommerce-for-user-behavior-tracking.md).

# Integrating Heap Analytics with PeakCommerce for User Behavior Tracking

### **Understanding Heap Analytics and PeakCommerce**

Heap Analytics is a robust analytics platform that automatically captures every user interaction on your website or application. From clicks to form submissions, Heap tracks it all without the need for manual event tracking, providing you with a comprehensive view of user behavior.

On the other hand, PeakCommerce is a leading e-commerce platform designed to optimize the online shopping experience. It empowers businesses to create seamless storefronts, commerce pages, subscription management, and more.

### **Why Integrate?**

Integrating Heap Analytics with PeakCommerce allows you to leverage the strengths of both platforms to gain a deeper understanding of your customers and their journey through your online store.

1. **Comprehensive Data Collection**: Heap automatically captures user interactions, while PeakCommerce provides detailed transactional data. By integrating the two, you get a holistic view of your customers' behavior from the first click to the final purchase.
2. **Personalized Insights**: With Heap's robust tracking capabilities and PeakCommerce's transactional data, you can create highly personalized experiences for your customers. Understand which products they're browsing, what motivates their purchases, and how you can tailor your offerings to better meet their needs.
3. **Optimized Conversions**: By analyzing user behavior across the entire customer journey, you can identify friction points and optimize your website to drive conversions. Whether it's streamlining the checkout process or refining product recommendations, integrating Heap Analytics with PeakCommerce helps you make data-driven decisions to boost sales.

### **How to Integrate Heap Analytics with PeakCommerce**

Integrating Heap Analytics with PeakCommerce is a straightforward process that can be done in just a few simple steps:

1. **Access Your Heap Analytics Account**: Log in to your Heap Analytics account and navigate to the "Settings" section.
2. **Obtain the installation code**: In the left navigation, click the install link. Follow the steps to retrieve the installation code you will use to install in PeakCommerce.
3. **Install in PeakCommerce**: Open the **user menu (bottom-left) → Settings → Tracking Scripts** (under *Developer Tools*), paste the installation code into the **Head scripts** field, and click **Save Tracking Scripts**. The snippet then loads on your public pages and journeys. Saving requires a system administrator, and you are always configuring the environment you're signed in to — paste your production Heap snippet on your production site.
4. **Map Events**: Once the integration is set up, you can start mapping Heap events to PeakCommerce actions. For example, you can track when users add items to their cart or complete a purchase.
5. **Monitor and Analyze**: With the integration in place, you can now monitor user behavior in real-time and analyze the data to gain valuable insights into your customers' preferences and habits.

#### Installation code in Heap

<figure><img src="/files/lvQwVwuujPEaTVp3Blry" alt=""><figcaption></figcaption></figure>

The code will have the form:

{% code overflow="wrap" lineNumbers="true" %}

```
<script type="text/javascript">
  window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.heapanalytics.com/js/heap-"+e+".js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a);for(var n=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","resetIdentity","removeEventProperty","setEventProperties","track","unsetEventProperty"],o=0;o<p.length;o++)heap[p[o]]=n(p[o])};
  heap.load("yourprojectid");
</script>
```

{% endcode %}

#### PeakCommerce Installation

Please note in the above Heap code example, the heap.load("yourprojectid") will need to be updated with your actual Heap Project Id. We recommend copying the code directly from Heap analytics and not using the code above as it may become outdated.

Heap auto-captures activity on your **public** storefront, signup, and journey pages. To also capture behavior in the **signed-in customer portal**, enable **Customer portal tracking** on the same Tracking Scripts page — behind-login pages never run tracking scripts until you deliberately switch this on, so identified-customer capture in the portal is always an explicit opt-in on your side.

### **Unlock the Power of Data-Driven E-commerce**

By integrating Heap Analytics with PeakCommerce, you can unlock the power of data-driven e-commerce. Gain deeper insights into your customers' behavior, personalize their shopping experience, and optimize your conversion funnel for maximum impact. Start integrating today and take your e-commerce strategy to new heights.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.peakcommerce.com/integrations/analytics-and-data/heap-analytics/integrating-heap-analytics-with-peakcommerce-for-user-behavior-tracking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
