Closed deltamualpha closed 2 months ago
Looks like a workaround is to:
Embedded analytic dashboard also isn't working, but not sure why that is yet.
Edit: this workaround no longer works as of the 2.0.5 release, which attempts to validate the API key to Plausible's servers on save.
I can confirm this is a bug, which'll be fixed in 2.0.3, which is about to be released in 3... 2... 1...
Embedded analytic dashboard also isn't working, but not sure why that is yet.
Same for this one, will be released in 2.0.3.
Still does not work with version 2.0.7. The data-domain
attribute is not added to the <script>
tag unless you provide a valid access token for the plausible hosted setting. Any random access token will not be accepted, as it's directly checked for validity.
Hmm, you're right. The API validation blocks saving the domain_name. I just created a fix for this. You can get the prerelease here.
I have the same issue, and I tried this prerelease, and it didn't work. I've downgraded to 1.3.6, which works well with my self-hosted setup (the backend is on the new Plausible Community Edition).
Does not work on the pre-release as @tenfourty mentioned, I'm still on the latest v1.3.x where everything works fine for me.
@Unkn0wn0x and @tenfourty, does the Domain Name option under the Self-Hosted tab contain a value in your configuration? Because that's how the plugin (the prerelease) checks if a self-hosted setup is being used, and if so, it doesn't attempt to validate the API token.
Yes, I have a value in the field, and I'm getting the error, AND I can't enter an API key.
If I remove the self-hosted info, I can enter an API key.
I don't know if this is related or if I should raise it as a separate issue, but the link to create an API key is hard-coded to plausible.io and doesn't consider the self-hosted URL.
This is still an issue in 2.0.8, should we re-open this issue or would you like me to open another one?
I have a domain set on the "Settings" tab (and no API token). And I have the plausible domain set in the "Self-Hosted" tab. And still the data-domain
comes up empty. This happens to me on two separate WordPress blogs.
investigating further, I can pinpoint the problem down to this
I added some echos for simple debugging here, and $domain_name
just comes up empty for me.
if $domain_name
worked, the first comment in the screenshot above would also contain something. But only the helper works correctly.
a var_dump
in the same place also confirms that $settings['domain_name']
contains an empty string. Please don't ask me why the get_settings()
does not work here when get_domain()
(which also calls get_settings()
internally) works. This is not my code. I only point out what works and what doesn't.
Replacing
- $domain_name = esc_html( $settings[ 'domain_name' ] );
+ $domain_name = esc_html( Helpers::get_domain() );
works fine for me and actually solves the problem.
@ccoenen and @deltamualpha, can you confirm if you're still experiencing this issue in v2.0.9? This release contains several improvements on the self-hosters (Plausible CE) side.
I just installed the latest version v2.0.9 and encountered the same issue.
yes, 2.0.9 still has the data-domain=""
attribute empty.
This then leads to this request failing with the error message that the data-domain needs to be filled.
I should say "again" has it empty, because this update nuked my fix that I had applied manually.
my fix from https://github.com/plausible/wordpress/issues/177#issuecomment-2049981781 still works. I just applied it and now it works fine again. It now needs to go in line 53:
- $domain_name = esc_html( $settings[ 'domain_name' ] );
+ $domain_name = esc_html( Helpers::get_domain() );
This way, the data-domain
attribute is filled correctly.
And that way, this request no longer fails with an HTTP 400 error.
And that way, I can get analytics on my self hosted plausible coming from my self hosted wordpress.
I investigated your fix @ccoenen and I think the reason why Helpers::get_domain()
works in your case, is because if the domain_name
option turns up as empty (for whatever reason) the Helpers function falls back to a regex to "guess" the domain name.
In short, implementing your fix will only work after handling #199.
We can confirm this issue. And just saying while interfering the domain name is great, there could be reasons to set a domain name in plausible that differes from the actual domain. Being able to optionally set a domain name would be preferable
@ccoenen I've applied your fix in this commit. So, it'll be included in v2.1.0.
thanks :-)
Howdy, I'm late to the party. Just posting for visiblity.
I wanted to confirm that installing 2.1.0-beta4 of the plugin resolved this for me.
Thanks for confirming. Closing this.
Can confirm that this issue did not come up for me again. Thank you to everyone involved :-)
Newly-installed plugin, latest version of both it and wordpress. Activated "self-hosted" mode, and see this being injected into the header:
<script defer data-domain='' data-api='https://<snip>/api/event' src="https://<snip>/js/plausible.outbound-links.js?ver=2.0.0" id="plausible"></script>
Tracing through the code, it looks like it's supposed to be filling in the
data-domain
from the plugin settings -- but those settings can only be updated if using the cloud, hosted version of Plausible.