diff --git a/CHANGELOG b/CHANGELOG index 126aac1af..e11a0f812 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ mkdocs-material-0.x.x (2016-xx-xx) + * Fixed webfont delivery problem when hosted in subdirectories + * Added option to configure fonts in mkdocs.yml with fallbacks * Set download link to latest version if available + * Set up tracking of outgoing links and actions for Google Analytics mkdocs-material-0.1.1 (2016-02-11) diff --git a/material/base.html b/material/base.html index c3f4cf18c..5cd799b4a 100644 --- a/material/base.html +++ b/material/base.html @@ -154,10 +154,21 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g; m.parentNode.insertBefore(a,m) })(window, document, - 'script', '//www.google-analytics.com/analytics.js','ga'); + 'script', '//www.google-analytics.com/analytics.js', 'ga'); + /* General initialization */ ga('create', '{{ google_analytics[0] }}', '{{ google_analytics[1] }}'); ga('set', 'anonymizeIp', true); ga('send', 'pageview'); + /* Track outbound links */ + var buttons = document.querySelectorAll('a'); + Array.prototype.map.call(buttons, function(item) { + if (item.host != window.location.host) { + item.addEventListener('click', function() { + var action = item.getAttribute('data-action') || 'follow'; + ga('send', 'event', 'outbound', action, item.href); + }); + } + }); {% endif %} diff --git a/src/base.html b/src/base.html index 26e88d27e..bfdbe1f71 100644 --- a/src/base.html +++ b/src/base.html @@ -237,11 +237,23 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g; m.parentNode.insertBefore(a,m) })(window, document, - 'script', '//www.google-analytics.com/analytics.js','ga'); + 'script', '//www.google-analytics.com/analytics.js', 'ga'); + /* General initialization */ ga('create', '{{ google_analytics[0] }}', '{{ google_analytics[1] }}'); ga('set', 'anonymizeIp', true); ga('send', 'pageview'); + + /* Track outbound links */ + var buttons = document.querySelectorAll('a'); + Array.prototype.map.call(buttons, function(item) { + if (item.host != window.location.host) { + item.addEventListener('click', function() { + var action = item.getAttribute('data-action') || 'follow'; + ga('send', 'event', 'outbound', action, item.href); + }); + } + }); {% endif %}