use document.referrer if no ref saved
fixed referrer bug