You've figured out already that you need to pass these values to another PHP script. There are several ways to do this, though none of them are very elegant and they all use JavaScript. One is to open a JavaScript popup window like so:
onLoad='javascript:void(temp=open('script.php?javascriptvars','dial','toolbar=no,scrollbars=no,resizable=no,menubar=no,status=no,directories=no,location=no,width=100,height=100'))
Have JavaScript fill in the stuff after "script.php?" .. then have the PHP script generate the JavaScript code to close the window once it's gathered the data. One problem with this method is that many users (including myself) have been trained to close popup windows before they've a chance to load.
A second option would be to have a very small (1x1) image tag near the top of your page. Have this image point to a PHP script in a similar method as above (have JavaScript fill in values after the question mark), and once the script has collected the data, have it return the image data, a la include("1x1image.gif");. Just make sure you don't return any text in the same script -- you may also need to use header() to tell the browser that you're returning an image.
One of these methods should work for you -- I'd recommend the second. Many free stats services (e.g. Stats4All) use a similar method to collect similar data.