Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get the referrer?

I have a website on which I dynamically create Javascript code using ASP.NET handler in which I should add the referrer to a database.

I want to get referrer of referrer like so:

  • website1
  • website2 (where I create pixel to another site)
  • website3 (where pixel is located)

I don't have code access to website1, on website2 I can only assign JavaScript.

If I get referrer in current application state I get website2.

Is there a way to get website1 as referrer?

like image 405
eugeneK Avatar asked Jul 28 '11 09:07

eugeneK


People also ask

How do I find a referrer?

To check the Referer in action go to Inspect Element -> Network check the request header for Referer like below. Referer header is highlighted. Supported Browsers: The browsers are compatible with HTTP header Referer are listed below: Google Chrome.

How do I get a referrer URL?

$_SERVER['HTTP_REFERER'] will give you the referrer page's URL if there exists any. If users use a bookmark or directly visit your site by manually typing in the URL, http_referer will be empty.

Who is your referrer?

Referrer definitionA person who refers another.

What is request referrer?

The Referer HTTP request header contains an absolute or partial address of the page that makes the request. The Referer header allows a server to identify a page where people are visiting it from. This data can be used for analytics, logging, optimized caching, and more.


1 Answers

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="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.

like image 105
Tom Avatar answered Oct 07 '22 15:10

Tom