Google Tag Manager Installation

Like any script, Heap can be installed via Google Tag Manager, or GTM for short. Because of the way GTM works, we strongly recommend setting the highest priority for Heap to be loaded.

To install, add the Heap snippet as a custom HTML tag and set it to fire on All Pages.

<script type="text/javascript">
    window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:":"http:")+"//"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};


If you have not yet installed Heap, you’ll find your snippet on our install page. If using the snippet above, remember to replace YOUR_APP_ID with the ID of the environment to which you want to send data. You can find this ID on the Account > Manage > Projects page.

GTM waits until the page fully loads to load its scripts. So if a user navigates away from the page before Heap loads, that data point will be lost. If you are using our client-side API, calls that are normally stubbed before the page loads, like calls to identify or addEventProperties, can get dropped.

Updated 11 months ago

Google Tag Manager Installation

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.