ruby on rails - Turbolinks not rendering code on page change -


i'm using segment.io tracking on site. have live chat widget i'd displayed on every page. i'm unable figure out how make work.

i've created analytics.js loads in body (i've tried adding analytics.page(); body without results):

  window.analytics = window.analytics || [];    window.analytics.methods = ['identify', 'group', 'track',     'page', 'pageview', 'alias', 'ready', 'on', 'once', 'off',     'tracklink', 'trackform', 'trackclick', 'tracksubmit'];    window.analytics.factory = function(method){     return function(){       var args = array.prototype.slice.call(arguments);       args.unshift(method);       window.analytics.push(args);       return window.analytics;     };   };    (var = 0; < window.analytics.methods.length; i++) {     var key = window.analytics.methods[i];     window.analytics[key] = window.analytics.factory(key);   }    window.analytics.load = function(key){     if (document.getelementbyid('analytics-js')) return;      var script = document.createelement('script');     script.type = 'text/javascript';     script.id = 'analytics-js';     script.async = true;     script.src = ('https:' === document.location.protocol       ? 'https://' : 'http://')       + 'cdn.segment.io/analytics.js/v1/'       + key + '/analytics.min.js';      var first = document.getelementsbytagname('script')[0];     first.parentnode.insertbefore(script, first);   };    window.analytics.snippet_version = '3.1.0';   window.analytics.load('kydwup6nxi');   window.analytics.page();    document.addeventlistener("turbolinks:load", function() {     console.log('page change');     analytics.page();   }); 

when visit new page on app shows console log, analytics.page(); doesn't seem rendered except when manual page refresh.

anybody know how fix this?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -