<p>All of the HTML that Craft uses to render your site lives in your <code>craft/templates</code> folder.</p>

<p>In one of the files in that folder, you're presumably defining your <code>&lt;head&gt;&lt;/head&gt;</code> tags.</p>

<p>You'd want to find where that is and insert your JavaScript analytics tracking code before the closing head as per the Head Analytics installation docs.</p>

<p>Probably worth a read through the <a href="https://craftcms.com/docs/introduction" rel="nofollow noreferrer">Craft does</a> to familiarize yourself with Craft concepts as well.</p>

CC BY-SA 3.0
2017-06-01T21:51:19.897Z
2017-06-01T21:51:19.897Z
Brad Bell
<p>I'm trying to add Heap Analytics as a tracking tool to my Craft site. From Heap's installation docs, I need to add this code snippet before the closing  tag. I'm pretty new to using Craft, can someone please explain how to go about doing this? </p>

<p>Code snippet: </p>

<pre><code>&lt;script type="text/javascript"&gt;
    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:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c&lt;p.length;c++)heap[p[c]]=o(p[c])};
    heap.load("YOUR_APP_ID");
&lt;/script&gt;
</code></pre>

<p>Heap installation instructions: <a href="https://docs.heapanalytics.com/docs/installation" rel="nofollow noreferrer">https://docs.heapanalytics.com/docs/installation</a></p>

<templating><analytics>
Add Heap Analytics code to HTML
# Add Heap Analytics code to HTML

(Asked by: username_0 on 2017-06-01)

I'm trying to add Heap Analytics as a tracking tool to my Craft site. From Heap's installation docs, I need to add this code snippet before the closing  tag. I'm pretty new to using Craft, can someone please explain how to go about doing this? 
Code snippet: 


Heap installation instructions: https://docs.heapanalytics.com/docs/installation

**Tags:** templating, analytics

---

## 1 answers

### Answer by username_1 on 2017-06-01. Score: 0 | Accepted answer

All of the HTML that Craft uses to render your site lives in your `craft/templates` folder.

In one of the files in that folder, you're presumably defining your  tags.

You'd want to find where that is and insert your JavaScript analytics tracking code before the closing head as per the Head Analytics installation docs.

Probably worth a read through the [Craft does](https://craftcms.com/docs/introduction) to familiarize yourself with Craft concepts as well.


---

