altimac
Forum Replies Created
-
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Thanks, Daan and no worries, I appreciate the response. Based on the tutorial link you sent, I have been using v. 2.5.6 of the plugin on 7 sites now after deleting all my Cloudflare workers and re-doing the Cloudflare proxy steps per the tutorial, which are now much simpler and don’t appear to require any routes to be added as before. When I upgraded from 2.5.0 to 2.5.6 that managed to literally caused my sites to time out, so I had to delete any prior version completely, then install 2.5.6 and reconfigure the plugin settings.
In any case, the stats are working, and no errors when I load the JavaScript for the proxy directly in a browser. Based on what I see on the forum, I am the only person on the planet who is using PA CE with Cloudflare proxies, so I don’t know if I’m going to get anyone to weigh in on that. I did read through the entire WP plugin section in the Plausible docs, and nowhere does it mention whether or not using a code snippet instead of the plugin does essentially the same thing or not. So I guess that will forever remain a mystery ;-(Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Hi, Daan. Just checking on those two things for which I can’t seem to find an answer, one being whether I should be using my PA CE host’s domain in the “Settings > Community Edition > Plausible Community Edition > Domain Name” field, or the client’s domain if I am proxying the stats via a Cloudflare worker, and the second being, if using the Plausible WordPress plugin adds any features for Plausible CE that are not available vis the code snippet.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Got it, if the other folks at Plausible can weigh in on that, it would be really helpful, and in the meantime I’ll re-do one of my Cloudflare workers as a test and see if I can get that working correctly as a proxy. I’m also still wondering if I should be using my PA CE host’s domain in the Settings > Community Edition > Plausible Community Edition > Domain Name field, or I should use the client’s domain, and I can’t locate any reference to that in the docs.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Well, what I’m asking is, does the WordPress plugin add additional options beyond what the code snippet method of installation does? Or to put it another way, is the ONLY difference between simply adding the code snippet to the site header vs. using the WordPress plugin simply that it’s more convenient? I’d rather make it simple and use the code snippet, but I don’t want to miss out on any additional features that the plugin adds.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Wow, that is completely and utterly different than what I have been using ;-( At least that explains why it’s not working with > 2.5.0 plugin version. I am going to set one domain up as a test and just use the snippet instead of the plugin for starters, since now I’m not sure what the plugin adds to the equation other than it’s what WordPress users are used to? Are there any benefits to using the WP plugin vs. the code snippet, if all your sites are running WordPress with Plausible CE?
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?OK, apologies for the length of this message, but as far as I can tell, I have configured the proxy script according to the Plausible CE docs. These are the routes I set up at Cloudways:
workers.dev. bbh-socrates-proxy.altim.workers.dev
Preview URLs -bbh-socrates-proxy.altim.workers.dev
Route bbhistory.org/js/
Route bbhistory.org/api/*
Route .bbhistory.org/js/
Route .bbhistory.org/api/and this is the worker script:
/*
* Plausible Analytics Proxy - Cloudflare Worker
*
* This worker proxies Plausible Analytics requests through the client's domain
* to bypass ad blockers and maintain first-party analytics.
*
* Setup Instructions:
* 1. Update the PLAUSIBLE_HOST constant below with your Plausible server
* 2. Optionally customize SCRIPT_PATH and API_PATH for extra ad-blocker evasion
* 3. Deploy this worker to the client's Cloudflare account
* 4. Add a route: clientdomain.com/js/* and clientdomain.com/api/*
* (or use your custom paths if you changed them)
*/
// ============================================
// CONFIGURATION - UPDATE THESE FOR EACH CLIENT
// ============================================
// Your Plausible Analytics server hostname
const PLAUSIBLE_HOST = 'socrates.altimac.com';
// Optional: Customize these paths for extra ad-blocker evasion
// Standard paths work fine, but you can use alternatives like:
// '/assets/analytics.js' or '/static/tracker.js' instead of '/js/script.js'
// '/track' or '/collect' instead of '/api/event'
const SCRIPT_PATH = '/js/script.js';
const API_PATH = '/api/event';
// Optional: Add any additional script extensions you use
// e.g., 'script.outbound-links.js', 'script.hash.js', etc.
const ADDITIONAL_SCRIPTS = [
'/js/script.outbound-links.js',
'/js/script.hash.js',
'/js/script.file-downloads.js',
'/js/script.tagged-events.js',
'/js/script.pageview-props.js',
// Add more as needed
];
// ============================================
// WORKER CODE - NO NEED TO MODIFY BELOW
// ============================================
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url);
const path = url.pathname;
// This part needs to work with the header code added by the Plausible WordPress plugin
// Which means our JavaScript is named "plausible.outbound-links.file-downloads.pageview-props.js"
// instead of just "script.js." So our path statements need to include not only the default
// path.startsWith('/js/script')
// but also
// path.startsWith('/js/plausible')
// And lastly, to allow for embedding the analytics in the WordPress admin dashboard, we add
// path.startsWith('/js/embed')
if ((path.startsWith('/js/script') || path.startsWith('/js/plausible') || path.startsWith('/js/embed')) && path.endsWith('.js')) {
return proxyScript(request, path);
}
// Check if this is a request for additional scripts
if (ADDITIONAL_SCRIPTS.includes(path)) {
return proxyScript(request, path);
}
// Check if this is an analytics event
if (path === API_PATH) {
return proxyEvent(request);
}
// Not an analytics request - return 404
return new Response('Not Found', { status: 404 });
}
/**
* Proxy the analytics script from Plausible server
*/
async function proxyScript(request, scriptPath) {
try {
const plausibleUrl =https://${PLAUSIBLE_HOST}${scriptPath};
const response = await fetch(plausibleUrl, {
method: 'GET',
headers: {
'User-Agent': request.headers.get('User-Agent') || '',
},
});
// Create new response with CORS headers
const newResponse = new Response(response.body, response);
// Set appropriate headers
newResponse.headers.set('Access-Control-Allow-Origin', '*');
newResponse.headers.set('Content-Type', 'application/javascript');
// Cache the script for 1 hour
newResponse.headers.set('Cache-Control', 'public, max-age=3600');
return newResponse;
} catch (error) {
console.error('Error proxying script:', error);
return new Response('Error loading analytics script', { status: 500 });
}
}
/**
* Proxy analytics events to Plausible server
*/
async function proxyEvent(request) {
try {
const plausibleUrl =https://${PLAUSIBLE_HOST}${API_PATH};
// Clone the request but change the URL
const modifiedRequest = new Request(plausibleUrl, {
method: request.method,
headers: request.headers,
body: request.body,
});
const response = await fetch(modifiedRequest);
// Create new response with CORS headers
const newResponse = new Response(response.body, response);
// Set CORS headers for POST requests
newResponse.headers.set('Access-Control-Allow-Origin', '*');
newResponse.headers.set('Access-Control-Allow-Methods', 'POST, OPTIONS');
newResponse.headers.set('Access-Control-Allow-Headers', 'Content-Type');
return newResponse;
} catch (error) {
console.error('Error proxying event:', error);
return new Response('Error sending analytics event', { status: 500 });
}
}
/**
* Handle CORS preflight requests
*/
function handleOptions(request) {
return new Response(null, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Max-Age': '86400',
},
});
}Is there anything about that that seems like it would not work as intended? Again, this was working with 2.5.0.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?OK, I think this might have something to do with the issue. Below is the PA CE script from two of my sites, one is using the 2.5.0 version of the plugin and one is using the 2.5.6 version.
This is from the 2.5.6 version site (bbhhistory.org):<script type="text/javascript" id="plausible-form-submit-integration-js-extra">
/* <![CDATA[ */
var plausible_analytics_i18n = {"form_completions":"WP Form Completions"};
//# sourceURL=plausible-form-submit-integration-js-extra
/* ]]> */
</script>
<script type="text/javascript" src="https://bbhistory.org/wp-content/plugins/plausible-analytics/assets/dist/js/plausible-form-submit-integration.js?ver=1772722517" id="plausible-form-submit-integration-js"></script>and this is from the 2.5.0 version site (starnewsgroup.com):
<script type="text/javascript" defer data-domain='starnewsgroup.com' data-api='https://starnewsgroup.com/api/event' data-cfasync='false' src="https://starnewsgroup.com/js/plausible.outbound-links.file-downloads.pageview-props.js?ver=2.5.0" id="plausible-analytics-js"></script>
<script type="text/javascript" id="plausible-analytics-js-after">
/* <![CDATA[ */
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }
//# sourceURL=plausible-analytics-js-after
/* ]]> */
</script>
<script type="text/javascript" id="plausible-form-submit-integration-js-extra">
/* <![CDATA[ */
var plausible_analytics_i18n = {"form_completions":"WP Form Completions"};
//# sourceURL=plausible-form-submit-integration-js-extra
/* ]]> */
</script>
<script type="text/javascript" src="https://starnewsgroup.com/wp-content/plugins/plausible-analytics/assets/dist/js/plausible-form-submit-integration.js?ver=1771847414" id="plausible-form-submit-integration-js"></script>Does that mean something changed with the plugin? The settings for the plugin are identical for both sites, other than for the Star News Group site, where it says:
If you’re using Plausible Community Edition on your own infrastructure, enter the domain name where you installed it to enable the integration with your self-hosted instance. Multisites can use the PLAUSIBLE_SELF_HOSTED_DOMAIN constant to define the URL for all subsites at once.
I have “starnewsgroup.com” entered there. But on the bbhistory.org site, running v. 2.5.6 of the plugin, I had to enter “socrates.altimac.com” in order for the stats to work at all; if I use “bbhistory.org” there, which is what was entered when I was using version 2.5.0, I get no stats at all.
Whether or not the plugin is causing this I really have no way of knowing, but it seems like something must have changed between 2.5.0 and 2.5.6? And I do have Cloudflare Workers set up for proxying, which I why I am using the client’s domain name in that field and not socrates.altimac.com, as I am thinking that will bypass the proxy completely, which I hope to not have to do.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Great, thank you. I’l do some experimenting and report back shortly. Appreciate your willingness to assist with this even though it seems as if it might be half proxy setup issue and half WordPress plugin issue ;-(
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Thanks, Daan. I could argue that it is the WordPress plugin, since 2.5.0 was working great for me but since the updates to 2.5.6 I still can’t get it to work as it did prior, and the forum appears to be for Plausible CE itself, not the WordPress plugin, which is what I’ve been having issues with. In any case, I think I’ll try removing the plugin and replacing it with the standard header script for CE, and see if I have better luck there. Thanks again for your help with this.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Sorry, one more thing, I updated Plausible CE to v. 3.2.0 and then updated one of my sites to the 2.5.6 version of the plugin. I also updated the plugin token, and the stats are working fine. BUT, I had set up a proxy on Cloudflare for this domain (bbhistory.org) so previously I was able to enter that domain in the Community Edition settings under Domain Name. But now the stats won’t register unless I use socrates.altimac.com (the host running Plausible) in that field, which I think is defeating the proxy? I completely understand if this level of assistance is above and beyond this support forum, but just figured I’d throw it out there. Thank you for all your help so far.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Got it, and thanks for the explanation.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.6 not recording all visits?Thanks so much for the quick response, Daan. Just curious, why does 2.5.0 still work but 2.5.6 does not?
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.2 not fixing all issuesGot it, the second I did the 2.5.3 update the site came back up. Again, it was always up from my end, but Uptime Kuma instantly confirmed it was up.
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.2 not fixing all issuesOK, great. Standing by…
Forum: Plugins
In reply to: [Plausible Analytics] 2.5.2 not fixing all issuesIt’s a 500 server error. If you’re talking about what “Tim” reported, I don’t know who he is or what he was experiencing. That’s why I was surprised to see the “Resolved” this morning.