Last active
July 27, 2016 23:39
-
-
Save sperand-io/ed4aed5112636adec7da04c4a192f68e to your computer and use it in GitHub Desktop.
Set heap super props before initial page call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.1.0"; | |
// add this line below | |
window.heap = window.heap || []; for (var n = ["clearEventProperties", "removeEventProperty", "addEventProperties", "setEventProperties", "unsetEventProperty", "addUserProperties", "identify", "track"], o = function(e) { return function() { window.heap.push([e].concat(Array.prototype.slice.call(arguments, 0))) }}, t = 0; t < n.length; t++) { var r = n[t]; window.heap[r] = o(r)}; | |
// now this works! see https://cldup.com/Z5trhErs9V.png | |
window.heap.addUserProperties({ testing: 'TEST' }); | |
analytics.load("YOUR_WRITE_KEY"); | |
analytics.page() | |
}}(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment