Forked from jittarao/Install Gist on Rails 5 Turbolinks.html
Created
May 10, 2020 20:10
-
-
Save sadiqmmm/fb22fe89cc9849541ff13b9809b80940 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!-- start Gist JS code--> | |
<script> | |
(function(){ | |
var loadEvent = 'turbolinks:load'; | |
var unloadEvent = 'turbolinks:before-visit'; | |
var loadHandler = function() { | |
document.removeEventListener(loadEvent, loadHandler); | |
document.addEventListener(unloadEvent, unloadHandler); | |
setTimeout(function () { | |
// Replace WORKSPACE_ID text with your Workspace ID | |
gist.setAppId("WORKSPACE_ID"); | |
gist.trackPageView(); | |
}, 500); | |
}; | |
var unloadHandler = function() { | |
document.removeEventListener(unloadEvent, unloadHandler); | |
delete (window.gist); | |
}; | |
document.addEventListener(loadEvent, loadHandler); | |
setTimeout(function() { | |
(function(d,h,w){var gist=w.gist=w.gist||[];gist.methods=['trackPageView','identify','track','setAppId'];gist.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);gist.push(e);return gist;}};for(var i=0;i<gist.methods.length;i++){var c=gist.methods[i];gist[c]=gist.factory(c)}s=d.createElement('script'),s.src="https://widget.getgist.com",s.async=!0,e=d.getElementsByTagName(h)[0],e.appendChild(s),s.addEventListener('load',function(e){},!1)})(document,'head',window); | |
}, 1); | |
})(); | |
</script> | |
<!-- end Gist JS code--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment