Everytime you load your analytics dashboard the plugin sends a dummy request to your tracking endpoint. When that request returns a non-OK value, it falls back to the default method and will then re-attempt installing the custom endpoint.
Are you sure that views were no longer being recorded?
Theoretically it could be that the incorrect path (after moving) was also writable on your host so the tracking request did not encounter anything wrong with it – but then the part that reads out this file later on (for long-term storage) would read out a different file (the new, correct, location).
__DIR__ can not be used in this case, as the writable uploads directory can live anywhere on your website and the file needs to know about this without having to load in the entirety of WordPress (because that wouldn’t be optimized anymore).
I’m not sure if the plugin stopped working, but even after checking the dashboard, stats and settings and even resaving the settings, the file was still pointing to the old and incorrect path. I didn’t say it stopped recording views. This is just about the file in the site root.
The new path wasn’t writable, because the directory structure was completely different (moving from Hostmonster/cPanel to Antagonist/DirectAdmin with different user account system).
I understand that it would need a different path structure in case the uploads directory is not on the default location. So that leaves the path check and the method of fixing that… 🤔
I’ve just tested this on my own server, by setting an invalid path in the endpoint, and as soon as I viewed Koko analytics in my dashboard it automatically reverted back to the correct path. So I think there may have been some other underlying issue if this didn’t happen for you.
Possibly the rights of the files didn’t copy over properly, and the file wasn’t writable on the new host?
The file was writable (I’ve checked in the backup) and I’ve done the things you did as well.
Could it be because the domain was still pointing to the old host, when I checked this? I was testing at that moment via an entry in my local hosts file.
If this really should work already, I guess I was too fast or there was some other rare issue. I’ll keep an eye on it for the next site I transfer. After all Koko is getting more popular, so there’s a bigger chance that a site is using it. 😉
Hard to say exactly what caused the issue in your case.
As we couldn’t replicate the issue and things are working fine when we try to change host in a test setup we will leave things as they are for now. If you do have the issue again you could email is and share login detail so we can debug the issue.