detect referr page

If I understand you correctly, a) a user goes to any website, b) user clicks on “random article”, c) user is redirected to a random article, d) user loads that random article. Am I correct thus far?

In that case, you’ll see the site from a) as your http referrer in d), because an HTTP Redirect doesn’t alter the referrer.

Options:

Don’t use HTTP to redirect, instead, use javascript. It’s slower, though.

Use HTTP to redirect, but add a token to the URL that you’re redirecting to, e.g. https://example.org/newPage/?utm_source=RandomArticle which you can then track. If you don’t want it into the URL bar the whole time, redirect to https://example.org/newPage/ after tracking it.

Or make it a client side info only by redirecting to https://example.org/newPage/#source=RandomArticle, since your analytics is most likely javascript based (Careful: make sure you don’t switch protocols when redirecting to a URL with a hash or safari might drop the hash info).

If you don’t want to manipulate the URL, set a cookie on redirect, read & overwrite it on the next page view.

Of course, if I didn’t understand you correctly this is all nonsense. In that case, please correct my assumptions.