1function segmentSnippet(key, userID) { 2 !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","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"; 3 analytics.load(key); 4 analytics.page(); 5 analytics.ready(function() { 6 setCookies(); 7 segmentIdentify(userID); 8 }) 9 }}(); 10} 11 12function setCookies() { 13 var anonID = window.analytics.user().anonymousId(); 14 document.cookie = 'segment_anon_id=' + anonID +';path=/'; 15 16 var userID = window.analytics.user().id(); 17 if (userID){ 18 document.cookie = 'segment_user_id=' + userID + ';path=/'; 19 } 20} 21 22// Make Segments identify() call UNLESS the user has just registered 23// (This lets us avoid potential duplicate Mixpanel records) 24function segmentIdentify(userID) { 25 if (!userID){ 26 return; 27 } 28 29 var urlParams = new URLSearchParams(window.location.search); 30 var newUser = urlParams.has('user_registered') 31 if (newUser){ 32 removeQueryFromURL('user_registered'); 33 return; 34 } 35 analytics.identify(userID); 36} 37 38function removeQueryFromURL(query) { 39 var urlParams = new URLSearchParams(window.location.search); 40 urlParams.delete(query); 41 if (urlParams.toString().length > 0){ 42 window.history.replaceState({}, null, location.pathname + '?' + urlParams); 43 return; 44 } 45 window.history.replaceState({}, null, '/'); 46 return; 47}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.