Some questions:
- Do you have control over
domain2.com ? - Do you have control over the external js that you are calling?
- If not, is there a way to pass another referent through a parameter?
You cannot change the reference page to call the service you are doing, to another service. However, the source code for domain2.com containing an external js call will have access to its own referrer domain1.com , and it needs to pass it as a parameter, providing a remote JS interface that allows passing the referencing parameter. This is available using the server code language that you are using. For example, here it is in PHP :
<script type="text/javascript"> var referer = "<?php echo $HTTP_REFERER; ?>"; doRemoteCall("theRemotePage?referer=" + referer); </script>
source share