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:
parent
e7efdade80
commit
a8534f7a48
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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 %}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user