Custom tracking script name
FarisZR opened this issue · 20 comments
Hello,
thanks for the awesome project!,
can you add the ability to customize the tracking script's name?
I use nginx rewrite to get past ad-blockers, and it would be useful if this component can support custom script names.
I don't understand what you need.
do you have an example for your use case ??
Sorry but still do not understand.
This project is usefull if you use the plausible script.
If you have control on your ngnix, why don't you make what you want/need on the rewrite part ??
I do not see how my module can help you in the ngnix use case.
Or more precisely I do not see why you can't just rewrite the script in the spirit of proxy_netlify.html
and use the basic code ?
I think that renaming the script is the job for the proxy
part and not for this module.
I provide the proxy_netlify.html
as a bonus. So it is sort of an "add-on" outside the module.
I know, what i am asking is for this module, to use the new and proxied script name. Not the standrad name. Instead of calling plausible.server.com/js/pausible.js, it would call the custom script name specified by the user, like plausible.server.com/js/newname.js
Yes I understand.
This is why i'm telling you that this is the work for the proxy
/ rewrite
part. And not this module.
Just take the proxy_netlify.html
idea and code this same principle in your ngnix conf.
I think it is just this.
When you've done it I can add your ngnix conf to the project.
I have NO WAY to do this in the module.
This only can be done on the proxy side (netlify or ngnix, apache, whatever)
And I do think that if you still, call from plausible.server.com
this will not bypass the adblockers.
Whatever the script name is.
OK. I saw that you have a clean way of doing it :
<script async defer data-domain="aosus.org" src="https://pa.aosus.org/js/pls4.js"></script>
But I'm really sorry ... i just do not understand the point.
My module JUST call the right script from plausible.io
according to variables.
Just that.
AFTER this, and because I use Netlify I rewrite the origin+script name for something else in my netlify conf.
And I provide as a bonus a partial for this : proxy_netlify.html
In your case if I use the domain name pa.aosus.org
I would have written this:
# Redirects for plausible.io & github.com/divinerites/plausible-hugo
{{- if site.Params.plausible.outbound_link }}
/js/pls4.js https://plausible.io/js/plausible.outbound-links.js 200
{{- else }}
/js/pls4.js https://plausible.io/js/plausible.js 200
{{- end }}
/api/event https://plausible.io/api/event 200
And this would generate your <script async defer data-domain="aosus.org" src="https://pa.aosus.org/js/pls4.js"></script>
or so.
You are asking for something that I (or anyone) can't do inside this module.
Would the module use /js/s/pls4.js instead of directly conneting to plausible?
Sorry, but I think you're missing something on the way all this works.
It is the other way ; YOU rename the plausible script in whatever you want.
about a way to change the name of the script used in the module
I'm still far away to understand why you still looking for this rename thing in THIS module, as it is a EXTERNAL job to do.
Still puzzled with your request and the lack of trying to do this outside the script.
Also this projects seems to not support Self-hosted Plausible instances, is that right?
I do not use it myself, but we have a self hosting option
[params.plausible]
selfhosted_domain = "myplausible.example.com" # Self-hosted plausible domain
If you look at this partial plausible_redirects_netlify.html, it is just something created for netlify users, but this partial is OUTSIDE the real module.
Just do the same with your context.
In short : I WILL NOT change the scripts name in this module. NOT.
That comment was an email that was probably stuck on sending a long time ago.
Sorry to re-open the issue!
I have made the change that I think you want, and was certainly what I was after, here; https://github.com/steve-winter/plausible-hugo
New config param to enable changing the JS filename to whatever I want.
Thanks see my comment.
Reopening for now
OK. Got your comments on the PR.
So we all agree (@steve-winter & @FarisZR) :
- The option for changing the script name is concernin g self-hosting use case.
- In all other cases (using the polausible.io service), changing script name only can be done thru proxy rewrite.
- This is outside the scope of this module.
- We can add some extra partial for that if someone provide the code for the proxy.
- The example for this is the
plausible_redirects_netlify.html
exytra script - You could name it
plausible_redirects_MYPROXY.html
withMYPROXY
being the proxy real name.
- The example for this is the
Are we all ok with this ? If yes i will make the change base on your PR.
Hi, thanks for your work.
It would be great if I could customize the tracking script name.
Are you planning on merging @steve-winter's fix ?