watch outbound links
This commit is contained in:
parent
02732645da
commit
82ae1ef877
1 changed files with 12 additions and 0 deletions
|
@ -58,8 +58,20 @@ function addEffect({ target }: UIEvent) {
|
|||
})
|
||||
}
|
||||
|
||||
function attend({ target}: UIEvent) {
|
||||
if (!isElement(target) || !target.matches("a[href][target=_blank]")) {
|
||||
return
|
||||
}
|
||||
umami?.track(`Link: ${target['innerText'] ?? target.getAttribute('href')}`, {
|
||||
from: document.location.href,
|
||||
destination: target.getAttribute('href'),
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener("mouseenter", addEffect, true)
|
||||
document.addEventListener("focus", addEffect, true)
|
||||
|
||||
document.addEventListener("mouseleave", removeEffect, true)
|
||||
document.addEventListener("blur", removeEffect, true)
|
||||
|
||||
document.addEventListener("click", attend, true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue