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

Events are sent to the wrong domain #124

Open
stefanofusai opened this issue Jun 17, 2024 · 4 comments
Open

Events are sent to the wrong domain #124

stefanofusai opened this issue Jun 17, 2024 · 4 comments

Comments

@stefanofusai
Copy link

stefanofusai commented Jun 17, 2024

First of all, thank you for your library! Unfortunately, I can't get it to work :(

I have my site hosted at placeholder.com, and my Plausible instance running (selfhosted) at analytics.placeholder.com
Unfortunately, the library tries to access the script.js file at placeholder.com, resulting in a 404, and I can't seem to change this.

Here is my next.config.js:

if (!process.env.PLAUSIBLE_DOMAIN) {
    throw new Error("Please set the PLAUSIBLE_DOMAIN environment variable");
}

module.exports = withPlausibleProxy({
    customDomain: process.env.PLAUSIBLE_DOMAIN, // PLAUSIBLE_DOMAIN = https://analytics.placeholder.com
})(nextConfig);

And here is my layout.tsx:

if (!process.env.DOMAIN) {
    throw new Error("Please set the DOMAIN environment variable");
}

return (
    <html lang={lang} suppressHydrationWarning>
        <head>
            <PlausibleProvider domain={process.env.DOMAIN} /> {/* DOMAIN = https://placeholder.com */}
            ...
        </head>
        <body
            ...
        </body>
    </html>
);

What am I doing wrong? Thank you!

@stefanofusai stefanofusai changed the title Events are sent to the wrong path Events are sent to the wrong domain Jun 17, 2024
@nirav24
Copy link

nirav24 commented Jul 4, 2024

I was able to make it work with my self-hosted plausible instance

Can you try

<PlausibleProvider domain={process.env.DOMAIN} 
customDomain="https://analytics.placeholder.com" selfHosted={true} />

@stefanofusai
Copy link
Author

I was able to make it work with my self-hosted plausible instance

Can you try

<PlausibleProvider domain={process.env.DOMAIN} 
customDomain="https://analytics.placeholder.com" selfHosted={true} />

Thank you for your help, unfortunately this still doesn't work. What does your process.env.DOMAIN look like?

@nirav24
Copy link

nirav24 commented Jul 4, 2024

I have it hardcoded to my website's DNS which also matches with plausible's website dns

EDIT: I have domain without https://

@stefanofusai
Copy link
Author

I have it hardcoded to my website's DNS which also matches with plausible's website dns

EDIT: I have domain without https://

Thank you for your help. It still seems like requests are not being sent out. I'm really not sure what I'm doing wrong

next.config.js

module.exports = withPlausibleProxy({
    customDomain: process.env.PLAUSIBLE_CUSTOM_DOMAIN, // https://analytics.example.com
})(nextConfig);

layout.tsx

<head>
    <PlausibleProvider
        domain={process.env.PLAUSIBLE_DOMAIN} // example.com
        customDomain={process.env.PLAUSIBLE_CUSTOM_DOMAIN} // https://analytics.example.com
        selfHosted={true}
    />

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