If you use Turbolinks, the ready event does not fire after loading the first page, so you need to bind to custom turbolinks events, for example page:load , for example:
var ready; ready = function() { var currentLocation = window.location.hostname; var lastLocation = document.referrer; if (lastLocation.indexOf(currentLocation) > -1) { } else { mixpanel.track("New Session", {}); } mixpanel.track("Page View", {}); }; $(document).ready(ready); $(document).on('page:load', ready);
For Rails 5, the event name changed to turbolinks:load
source share