I'm trying to add an on-page "back" link that will only appear if the referrer was the home domain.
I have been through a number of threads on here which have been very helpful, but my code does not work despite being a combination of others' supposedly working code. I am at a loss as to why:
if (document.referrer.indexOf('MyDomain') > -1) {
document.write('<a href="' + document.referrer + '"><<Back to Results</a>');
}
When the referrer is on my domain it works as intended, but when the referrer is not on my domain it still writes the link.