You can pass this value along: document.referrer
.
That expression would need to be evaluated on website 2, not on website 3.
So:
// website2.html
<img src="https://stackoverflow.com/questions/6856697/website3.com/pxl.gif" id="pxl" />
<script>
document.getElementById('pxl').src += '?ref=" + encodeURIComponent(document.referrer);
</script>
The request to website3 will then include the referrer.