1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-09-24 03:18:21 +02:00

Fixed analytics events for own documentation

This commit is contained in:
squidfunk 2021-06-06 16:28:30 +02:00
parent e7efdade80
commit a8534f7a48
4 changed files with 9 additions and 8 deletions

View File

@ -35,5 +35,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.f989075e.min.js' | url }}"></script>
<script src="{{ 'overrides/assets/javascripts/bundle.52d656d3.min.js' | url }}"></script>
{% endblock %}

View File

@ -30,11 +30,12 @@ import { fromEvent } from "rxjs"
* Set up extra analytics events
*/
export function setupAnalytics(): void {
const { origin } = new URL(location.href)
fromEvent(document.body, "click")
.subscribe(ev => {
if (ev.target instanceof HTMLElement) {
const el = ev.target.closest("a[href^=http]")
if (el instanceof HTMLLinkElement)
const el = ev.target.closest("a")
if (el && el.origin !== origin)
ga("send", "event", "outbound", "click", el.href)
}
})