Seeing the comments I tell you that I do not know a way to do it without using a database to post the users (Thing that does not make sense because for that you would make requests to the server that is what you do not want)
However, I present a possible solution to fix your problem:
Is to create a script that is based on mathematics, and control everything by probability, you can change the probability:
<script>
//use window en lugar del método de jQuery para que sin importar dónde coloque este script este espere a que carguen todos los recuesos (incluendo jQuery) y funcione de manera correcta, de otro modo podrían haber fallos.
window.onload = function (){
let num = Math.round(Math.random()*100); //generar un numero entre 0 y 100 y guardarlo en una variable llamada num
if(num==0){num = 1} //para evitar que sean 101 numeros y sólo sean 100
if(num>=75 && num<=100){ //sólo hay 25 numeros que corresponden osea 25%
$.post(tusParametros); //tu peticion post de ajax
}
}
</script>
For this script, a 25% chance is generated that the request is made but you can change it, that way not all users will generate the ajax request.
Limit it to anonymous or unlogged users
I suppose you should have an authentication system, I do not know it but being the most common php sessions I recommend the following, if you use another system you tell me and I'll see if I can find how to implement it.
<?php
if(isset($_SESSION['usuario'])){ //algo muy simple pero es la idea
require 'somepage.php';
}else{
require 'miScript.php';
}
?>
In this case if you are a user you will include the code which always makes the request but you will not include the code of the request that is based on the probability.
For my example somepage.php
would contain the request that is always made so that the users with session started have the benefit and miScript.php
would have only the code that makes random requests.
Why do the files that contain the script have an .php extension?
-If you need to have HTML or PHP or JS code you can have it in that same file
-Follow my knowledge is the same do a require a .js file, this would literally get the text that is in the