Tweak tracking scripts

pull/620/head
Thibaut Courouble 8 years ago
parent 9d919591c2
commit 6b5f9a1088

@ -52,7 +52,7 @@ page.replace = (path, state, skipDispatch, init) ->
page.dispatch(context) unless skipDispatch page.dispatch(context) unless skipDispatch
context.replaceState() context.replaceState()
updateCanonicalLink() updateCanonicalLink()
track() unless init or skipDispatch track() unless skipDispatch
context context
page.dispatch = (context) -> page.dispatch = (context) ->
@ -185,7 +185,12 @@ updateCanonicalLink = ->
@canonicalLink ||= document.head.querySelector('link[rel="canonical"]') @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
@canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}") @canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")
trackers = []
page.track = (fn) ->
trackers.push(fn)
return
track = -> track = ->
ga?('send', 'pageview', location.pathname + location.search + location.hash) tracker.call() for tracker in trackers
_gauges?.push(['track'])
return return

@ -1,20 +1,28 @@
try { try {
if (app.config.env == 'production') { if (app.config.env == 'production') {
(function() { (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-5544833-12', 'devdocs.io');
ga('create', 'UA-5544833-12', 'devdocs.io'); page.track(function() {
ga('send', 'pageview'); ga('send', 'pageview', {
})(); page: location.pathname + location.search + location.hash,
dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
});
});
(function() { page.track(function() {
var _gauges=_gauges||[];!function(){var a=document.createElement("script"); if (window._gauges)
a.type="text/javascript",a.async=!0,a.id="gauges-tracker", _gauges.push(['track']);
a.setAttribute("data-site-id","51c15f82613f5d7819000067"), else
a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; (function() {
b.parentNode.insertBefore(a,b)}(); var _gauges=_gauges||[];!function(){var a=document.createElement("script");
})(); a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
b.parentNode.insertBefore(a,b)}();
})();
});
} }
} catch(e) { } } catch(e) { }

Loading…
Cancel
Save