detect referr page

I made custom template to randomly redirect users to posts with specific args

I need to know if users reach the post from this page link or from another one

I tried wp_get_referer();

but it's get the place which I clicked the link on to reach the page

on short ( I need to know if user reach this url through redirecting from example.com?pageid=1 or not

I am using wp_redirect ( get_permalink ( $post-ID ) ); for redirecting

any Idea will be appreciated

Topic cookies references Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.