1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 09:20:52 +01: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 %} {% endblock %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.f989075e.min.js' | url }}"></script> <script src="{{ 'overrides/assets/javascripts/bundle.52d656d3.min.js' | url }}"></script>
{% endblock %} {% endblock %}

View File

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