Created
February 22, 2018 14:09
-
-
Save scottwater/28c8a6438b14fb320c5e714557cce4c4 to your computer and use it in GitHub Desktop.
Sample KickoffLabs Segment Integration.
This file contains 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 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