Skip to content

Instantly share code, notes, and snippets.

@AdrienGiboire
Last active February 29, 2016 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdrienGiboire/3cc791d7e024c2e3b662 to your computer and use it in GitHub Desktop.
Save AdrienGiboire/3cc791d7e024c2e3b662 to your computer and use it in GitHub Desktop.
- prefix = Rails.env.production? ? '' : (Rails.env + ":")
:javascript
!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","group","track","ready","alias","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){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.0.1";
window.analytics.load("pa5hjwyc51");
window.analytics.page({name: "#{prefix}" + document.title});
}}();
-# I'm logged in to the following is actually called
- resource = current_user || current_youtuber || @waiting_youtuber
- if resource
:javascript
analytics.identify("#{resource.intercom_user_id}");
- if session[:segment_io_events]
- session[:segment_io_events].each do |event|
:javascript
analytics.track("#{prefix + event[0]}", #{JSON.generate(event[1])});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment