mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-12 01:50:52 +01: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)
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user