mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Set up tracking of outgoing links and actions for Google Analytics
This commit is contained in:
parent
863e1482dc
commit
cec4f1885b
@ -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)
|
||||
|
||||
|
@ -155,9 +155,20 @@
|
||||
m.parentNode.insertBefore(a,m)
|
||||
})(window, document,
|
||||
'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);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
@ -239,9 +239,21 @@
|
||||
})(window, document,
|
||||
'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);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user