pixelplicity / gatsby-plugin-plausible

Gatsby plugin to add Plausible analytics to your site.
MIT License
17 stars 21 forks source link

Selfhosted support #49

Open mannp opened 4 years ago

mannp commented 4 years ago

Hi there

Would it be possible for a tweak to add support for self hosted plausible instances please?

Perhaps another option selfhostedDomain: plausible.mydomain.com or selfhosted: true and use the customDomain still...?

allowing the creation of a url as follows;

ccummings commented 4 years ago

@mannp Using the customDomain option should be all you need. Let me know if I'm missing something.

mannp commented 4 years ago

@ccummings the customDomain creates a url with /js/index.js rather than /js/plausible.js when using it selfhosted.

I use a patched local copy of the plugin for my domain and I get to keep it updated with dependency updates....

I modified var scriptURI in gatsby-ssr.js to select my domain or plausible and it works, but not sure its any good for others.

Weetbix commented 3 years ago

This would be very useful! :)

Weetbix commented 3 years ago

For @mannp and others, a simpler workaround that doesnt involve any patching is to put the entire path in the custom domain and end with a query string, forcing the request to the correct file:

https://github.com/Weetbix/crossplayable.games/blob/main/gatsby-config.ts#L19

mannp commented 3 years ago

For @mannp and others, a simpler workaround that doesnt involve any patching is to put the entire path in the custom domain and end with a query string, forcing the request to the correct file:

https://github.com/Weetbix/crossplayable.games/blob/main/gatsby-config.ts#L19

Thanks @Weetbix I am good keeping my local version updated, with my website updates, but it certainly could help others.

dkoprowski commented 3 years ago

Thanks, @Weetbix for the workaround.

izackwu commented 3 years ago

@Weetbix That's really a clever work-around, thanks.

But for me, I chose to make some work-around on the server's side. I use Caddy for reverse proxy, so I just add one extra line to make things all right:

plausible.example.com {
  rewrite /js/index.js /js/plausible.js
}