title: What does heap analytics' script code do?
body: <p>So Heap Analytics tells me to paste this code in order to use their product -</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    window.heap=window.heap||[];heap.load=function(a){window._heapid=a;var b=document.createElement("script");b.type="text/javascript",b.async=!0,b.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.heapanalytics.com/js/heap.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c);var d=function(a){return function(){heap.push([a].concat(Array.prototype.slice.call(arguments,0)))}},e=["identify","track"];for(var f=0;f&lt;e.length;f++)heap[e[f]]=d(e[f])};
    heap.load("YOUR_APP_ID");
  &lt;/script&gt;
  </code></pre>
  
  <p>What does this code do? (barring all the app id stuff).</p>
  
  <p>I found something similar in the open source analytics.js </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  window.analytics||(window.analytics=[]),window.analytics.methods=["identify","track","trackLink","trackForm","trackClick","trackSubmit","page","pageview","ab","alias","ready","group","on","once","off"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i&lt;window.analytics.methods.length;i++){var method=window.analytics.methods[i];window.analytics[method]=window.analytics.factory(method)}window.analytics.load=function(t){var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)},window.analytics.SNIPPET_VERSION="2.0.8",
  window.analytics.load("YOUR_WRITE_KEY");
  window.analytics.page();
  &lt;/script&gt;
  </code></pre>
  
  <p>Is that doing something similar? (at a glance it looks like it)</p>