mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 04:25:39 +01:00
Allow setting custom data on autotracked pageviews via data attributes on script element
This commit is contained in:
parent
3656234b5a
commit
1fd997c374
1 changed files with 10 additions and 1 deletions
|
|
@ -39,6 +39,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
const getPageviewEventData = () => Object.fromEntries(
|
||||
[...currentScript.attributes]
|
||||
.filter(attribute => eventRegex.match(attribute.name))
|
||||
.map(attribute => {
|
||||
const match = attribute.name.match(eventRegex);
|
||||
return [match[1], attribute.value]
|
||||
})
|
||||
)
|
||||
|
||||
const getPayload = () => ({
|
||||
website,
|
||||
hostname,
|
||||
|
|
@ -207,7 +216,7 @@
|
|||
} else if (typeof obj === 'function') {
|
||||
return send(obj(getPayload()));
|
||||
}
|
||||
return send(getPayload());
|
||||
return send({ ...getPayload(), data: getPageviewEventData() });
|
||||
};
|
||||
|
||||
const identify = data => send({ ...getPayload(), data }, 'identify');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue