1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 17:30:56 +01:00
mkdocs-material/material/partials/integrations/analytics.html

28 lines
865 B
HTML

{#-
This file was automatically generated - do not edit
-#}
{% set analytics = config.google_analytics %}
<script>
window.ga = window.ga || function() {
(ga.q = ga.q || []).push(arguments)
}
ga.l = +new Date
/* Setup integration and send page view */
ga("create", "{{ analytics[0] }}", "{{ analytics[1] }}")
ga("set", "anonymizeIp", true)
ga("send", "pageview")
/* Register handler to log search on blur */
document.addEventListener("DOMContentLoaded", () => {
if (document.forms.search) {
var query = document.forms.search.query
query.addEventListener("blur", function() {
if (this.value) {
var path = document.location.pathname;
ga("send", "pageview", path + "?q=" + this.value)
}
})
}
})
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>