If there isn't, then simply include the referrer as one of the "browser details" that you capture and send back with the redirection instruction. The referrer probably isn't available on the client automatically, so it will work like this:
- Client sends initial request, presumably including a referrer.
- Server dynamically generates the client-side-testing page, including the referrer in a Javascript variable.
- Client collects client attributes, including the referrer value stored in step 2.
- Client sends collected attributes to server with new redirection request.
- Server records referrer parameter somewhere, although not in the HTTP logs since the Referer header won't have the same value as what the Javascript request sent.
Of course, you realize none of this is reliable anyway because it all depends on the client including the Referer header in step 1, and there's no guarantee that will happen, or if it does happen, that the value you get is accurate. I also question the wisdom of doing client-side checks (especially of something as arbitrary as window dimensions) to determine the validity of a navigation request.