mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +01:00
Adjusted tracking script to find parent a-tag for click tracking
This commit is contained in:
parent
b39ef68372
commit
a84d2181e7
@ -112,13 +112,21 @@
|
||||
};
|
||||
|
||||
const callback = e => {
|
||||
const findATagParent = (rootElem, maxSearchDepth) => {
|
||||
let currentElement = rootElem;
|
||||
for (let i = 0; i < maxSearchDepth; i++) {
|
||||
if (currentElement.tagName === 'A')
|
||||
return currentElement;
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const el = e.target;
|
||||
const anchor =
|
||||
el.tagName === 'A'
|
||||
? el
|
||||
: el.parentElement && el.parentElement.tagName === 'A'
|
||||
? el.parentElement
|
||||
: null;
|
||||
: findATagParent(el, 5);
|
||||
|
||||
if (anchor) {
|
||||
const { href, target } = anchor;
|
||||
|
Loading…
Reference in New Issue
Block a user