Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two scripts on the same website does not work. #3076

Open
nashschool opened this issue Nov 27, 2024 · 1 comment
Open

Two scripts on the same website does not work. #3076

nashschool opened this issue Nov 27, 2024 · 1 comment

Comments

@nashschool
Copy link

Describe the Bug

I have my website running on both Vercel and my own domain. I wanted to monitor traffic on both these. I added two umami scripts as:

`
const UmamiScripts = () => {
const umamiWebsiteIds =
process.env.NEXT_PUBLIC_UMAMI_WEBSITE_IDS?.split(',') || [];
console.log('id', umamiWebsiteIds);

return (
<>
{umamiWebsiteIds.map((id) => {
console.log('Loading script for website ID:', id);
return (
<Script key={id} src="/scripts/umami.js" data-website-id={id} strategy="lazyOnload" />
);
})}
</>
);
};
`

in .env I added the two website id's separated by a comma. The problem is only the first website shows up in the traffic and the second does not. I tried flipping the order in the env variable, and again it is the first website that is monitored and not the second.

Database

PostgreSQL

Relevant log output

No response

Which Umami version are you using? (if relevant)

No response

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

@franciscao633
Copy link
Collaborator

Looks like Next Script will only load the first script if the src remains the same. You can use the lowercase script if you want to map through your websites, but you can't include a strategy. Example output below would work with multiple scripts.

<script
  key="id1"
  src="/scripts/umami.js"
  data-website-id="websiteId1"
></script>
<script
  key="id2"
  src="/scripts/umami.js"
  data-website-id="websiteId2"
></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants