Last active
September 24, 2018 15:01
-
-
Save ktusznio/9179622e2accf137b3475c42d5b4a471 to your computer and use it in GitHub Desktop.
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
export function loadSegment(writeKey) { | |
if (!writeKey) { | |
throw new Error("loadSegment: blank writeKey."); | |
} | |
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", | |
"debug", | |
"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, e) { | |
var n = document.createElement("script"); | |
n.type = "text/javascript"; | |
n.async = !0; | |
n.src = | |
"https://cdn.segment.com/analytics.js/v1/" + t + "/analytics.min.js"; | |
var a = document.getElementsByTagName("script")[0]; | |
a.parentNode.insertBefore(n, a); | |
analytics._loadOptions = e; | |
}; | |
analytics.SNIPPET_VERSION = "4.1.0"; | |
analytics.load(writeKey); | |
analytics.page(); | |
} | |
} |
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
trackSelections = () => { | |
window.analytics.track("filter_change", { | |
...this.state.selections, | |
pods_count: this.pods.length, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment