Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample KickoffLabs Segment Integration.
<script type="text/javascript">
var segment_api_key = 'YOUR KEY HERE';
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(a){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(a),window.analytics.push(t),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var method=window.analytics.methods[i];window.analytics[method]=window.analytics.factory(method)}window.analytics.load=function(a){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"===document.location.protocol?"https://":"http://")+"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"+a+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)},window.analytics.SNIPPET_VERSION="2.0.6",
window.analytics.load(segment_api_key),
window.analytics.page();
</script>
<script type="text/javascript">
$(document).on('kol:knownlead', function(e, lead){
var user_data = {email: lead.email, social_url: lead.social_url};
$.extend(user_data, lead.custom_fields);
analytics.track('Sign up', user_data);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.