-
Hi everyone, <html lang={locale}>
<Script async defer
src="/stats/script.js"
data-website-id="..."
/>
<body>
...
</body>
</html> and then I fire track event, but until umami is loaded I get an error that umami is not defined. I've end up doing a busy waiting code which look like this: export const track = (event?: string) => {
if (typeof umami !== 'undefined') {
console.log('tracking event', event);
if (event) {
umami.track(event);
} else {
umami.track();
}
} else {
console.log('umami not available, retrying event', event);
setTimeout(() => {
track(event);
}, 1000);
}
} Is there a neater way to achieve it? |
Beta Was this translation helpful? Give feedback.
Answered by
orendecor
Nov 11, 2024
Replies: 1 comment
-
Found a solution using strategy='beforeInteractive' and put the Script inside an tag: <html lang={locale}>
<head>
<Script
src='/stats/script.js'
data-website-id={websiteId}
strategy='beforeInteractive'
async
/>
</head>
...
</html>
``` |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
orendecor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found a solution using strategy='beforeInteractive' and put the Script inside an tag: