Skip to content

Commit

Permalink
Improve analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
OreQr committed Oct 28, 2024
1 parent b69cbc0 commit c1041d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion embeds/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ function createIframe() {

const parentElement = currentScript.parentNode

const url = "/static/embeds/" + currentScript.getAttribute("embed")
const embedName = currentScript.getAttribute("embed")

const url = "/static/embeds/" + embedName

const iframe = document.createElement("iframe")

Expand All @@ -24,9 +26,20 @@ function createIframe() {
})

resizeObserver.observe(iframe.contentWindow.document.body)

// Analytics
iframe.contentWindow.document.addEventListener(
"click",
() => {
umami.track(`embed-${embedName}`)
},
{ once: true }
)
}

function updateIframeSize() {
if (!iframe.contentWindow) return

iframe.width = iframe.contentWindow.document.body.scrollWidth
iframe.height = iframe.contentWindow.document.body.scrollHeight
}
Expand Down
1 change: 1 addition & 0 deletions wiki/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
defer
src="https://umami.hostyard.eu/script.js"
data-website-id="cca01124-9d80-4709-a090-c2d5d8041207"
data-domains="wiki.hostyard.eu"
></script>

0 comments on commit c1041d9

Please sign in to comment.