mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +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 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 el = e.target;
|
||||||
const anchor =
|
const anchor =
|
||||||
el.tagName === 'A'
|
el.tagName === 'A'
|
||||||
? el
|
? el
|
||||||
: el.parentElement && el.parentElement.tagName === 'A'
|
: findATagParent(el, 5);
|
||||||
? el.parentElement
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (anchor) {
|
if (anchor) {
|
||||||
const { href, target } = anchor;
|
const { href, target } = anchor;
|
||||||
|
Loading…
Reference in New Issue
Block a user