xmlhttprequest only gets the domain instead of the full url. what should I do

I have open source software. I want to see who is using this. So with xmlhttprequest I POST the url of where my open source software is installed to my own website. On my own website the write.php file captures and saves them.

But on some servers this URL doesn’t work properly. For example, if the software is on example.com/file/123/1.html, the POST value I receive is only example.com.

What I want is to POST example.com/file/123/1.html but on some servers it only POSTs to example.com.

Can you help me please.

var url = "example.com/write.php";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      
   }};

var data = "url="+(location.href);

xhr.send(data);