Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save edwardsfriedman/17a66e22e5f5b81bf4e4470e9ce26f29 to your computer and use it in GitHub Desktop.
Save edwardsfriedman/17a66e22e5f5b81bf4e4470e9ce26f29 to your computer and use it in GitHub Desktop.
Heap super property implementation
<%# Enables heap super properties so heap will send properties even when called before it has loaded. %>
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)};
var locale = "<%= I18n.locale %>"
<%# Set locale as heap super property. %>
window.heap.addUserProperties({ locale: locale });
analytics.load("<%= segment_key %>");
analytics.track('Set Locale', {locale: locale});
//etc etc, with analytics.page() coming below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment