Saturday, January 23, 2010

How does your index.html capture the HTTP_REFERER?

By sending the "REFERRER" variable to cookie:

<script language="Javascript">
<!--

if (document.cookie.indexOf("url") == -1) {
document.cookie = "url=" + escape(document.referrer) + ";path=/";
}
//-->
</script>


The "document.referrer" contains the referrer's URL for any pages at all time. All you have to do is to send the content to the cookie. The cookie will record the first referrer data so that it will capture the source of the link to your website. The (document.cookie.indexOf("url") == -1) is to prevent the next click to corrupt your original referrer data stored in the "url" cookie.

You use scripts to send the "url" data to an email or database anytime now as the data is already captured into the cookie jar.


You can also open web server log to check through all the visitors but this is a very time-consuming way to run research on your visitors.


No comments:

Post a Comment