0

How to null and/or alter the value of referring URL?

I'm using Google Analytics and other some Analytics services. I found they are tracking Referral URL.

So I want to hide Referral URL from Traffic Analysis Tools

(e.g.:- modify $_SERVER["HTTP_REFERER"]; value to facebook.com on localhost)

index.php

<a href="get_referer.php"> Click Here</a>

get_referer.php

<?php
    $referer = $_SERVER["HTTP_REFERER"];
    echo $referer ;
?>
4
Contributors
6
Replies
55
Views
4 Years
Discussion Span
Last Post by vizz
0

If I understood your request, I think it cannot be done.
Since Google Analytics runs into an external javascript file, which is located in:

http://www.google-analytics.com/ga.js 

Or for SSL:

https://ssl.google-analytics.com/ga.js 

The referer cannot be changed by your server, but only by a client browser. This happens because when a page is opened, the browser sends the headers to all the resources requested by the page, including all the external files. So Google Analytics is creating a direct connection [browser] -> [google-analytics] without including your server, i.e. nothing like this: [browser] -> [your_server] -> [google-analytics]. The association with your website is done by the tracker ID code.

0

Also I can’t think a proper way that can be done. But a cheat answer would be to redirect a request to the same url if it hasn’t been redirected yet, server side with PHP and headers. The easy way to know if that URL has been redirected server side, not redirect it if so could be using a SESSION variable for example. This could be trickier if there is a POST request, but can be done too.
Edit: Of course that way you just “hide” the referrer to the current uri not cheat that the referrer is another one.

Edited by jkon

0

as per my knowledge, It can be done. I have seen this on many traffic generating site. You can check this

Addons are available for firefox

I just want to do this with coding. I want to add code on my site which will null the Referer Value

For php it is, $_SERVER["HTTP_REFERER"];
For javascript it is, document.referrer,

but I'm not successful to write referrer facebook.com instead localhost

0

@vizz if you are referring only to a local script to run, then yes it can be done:

<?php
    $ref_url = 'http://google.com/'; # this is the Referer
    $url = 'http://your_website.tld/target.php';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $ref_url);
    echo curl_exec ($ch);
    curl_close ($ch);
?>

But it works only if the request starts from a script (the above) asking for a page. Not sure if this is helpful for you, bye!

2

Any analytics tool that uses Javascript (basically all of them) just gets the referer from document.referrer in the DOM. This can't be overwritten with your own value but a lot of times the analytics tools let you override them. I work for an analytics company and we have a method as well.

Here is one for Google Analytics. https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking#gat.GA_Tracker._setReferrerOverride

I really don't see a good reason to override the referer in analytics.. that is one of the major parts of web analytics.

Votes + Comments
thanks for sharing
0

It is possible to cheat with Google Analytics in firefox using addons.

But how to do the same thing using php or javascript, like addons I posted above?

I have tested above addons, 1st one hides referer from Google Analytics

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.