Affordable Web Hosting with Excellent Customer Support internet connection free month hosting

netConsole: RefTracker

The RefTracker script was written at the request of one our clients. The client's site participated in a link exchange program and had also been spending money on pay-per-click advertising. To gauge the effectiveness of these two traffic-generating programs, he wanted to find out where his customers, not just his visitors, were coming from.

Visitor information is easy enough to come by. Our unix netConsole provides access to website traffic logs as well as reports generated from these logs. Details such as what websites and search engines are referring traffic to your site are contained within these reports. However, deciphering which of these visitors became a customer, and purchased something from a site, was not information provided by the reports. Thus, the RefTracker was created to provide this information.

The RefTracker relies on Apache's Rewrite engine and a perl script to function. If a visitor comes from somewhere off-site, they are redirected to the reftracker.cgi. The script grabs their HTTP_REFERER information which is saved in a cookie that is temporarily stored on their local machine. If they came from somewhere that is not off-site, from a bookmark, by direct request, or from another page on your site, there is no referrer information and a cookie is not created for them.

Once the cookie has been created, the visitor's referrer information is stored there and can be extracted for inclusion in an order form.

Installing RefTracker RefTracker is installed from the Package Installer section of your netConsole. Select "reftracker" from the drop-down menu and click the install button.

Extracting Cookie Data

Using JavaScript

When the RefTracker script is installed, a form page named reftracker.html is dropped into your webshare directory. This form page serves as an example on how to extract data from a cookie. By using JavaScript, we are able to "grab" the data that was stored in the visitor's cookie and include it in the form information. If you wish to employ a similar method for your site, ensure lines 4-27 are included in the head of your document:
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script language="JavaScript" type="text/javascript">
<!--
function get_cookie(key)
{
        var arg = key + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) {
                        var endstr = document.cookie.indexOf(";", j);
                        if (endstr == -)
                                endstr = document.cookie.length;
                        return unescape(document.cookie.substring(j,endstr));
                }
                i = document.cookie.indexOf(" ", i) + ;
                if (i == 0)
                        break;
        }
        return false;
}
-->
</script>
Then, add the following line to the body tag:

<body onLoad="document.forms.name-of-form.elements.name-of-form-field.value = get_cookie('used_referer');">

Take note of the 3 items in italic. The first, "name-of-form", is the name of your form. The second, "name-of-form-field" is the name of the field where you want the referrer information to be displayed.

For demonstration purposes, this form field is visible on the sample form page. In an actual working form, you'd probably want to make this field hidden.

The last item in italic, "used_referer", is the name of the cookie that stores the referrer information. This name is determined by the RefTracker script, not by your page or your form. Should you use some other method to extract the data within the cookie, you'll need to know the name of the cookie.

Using netShop

Another method of extracting cookie data is to use the netShop. This can be done on any form page with the following line:

<input type="text" value="<!--#exec cgi="path/to/cart.cgi?get-cookie:used_referer" -->" name="Referrer">

Note the name of the cookie in italic.

Cookies and SSL

In most cases this package will be used with an ordering process utilizing Secure Sockets Layer (SSL) to encrypt sensitive customer data. If your site uses Internet Connection's secure data services, SSLServer.com, and relies on our certificate, i.e. your secure pages are accessed by a URL similar to this one:

https://sslserver.com/your-domain-name/page.html

you will have to take special steps to preserve your cookie data. If you have your own certificate and access your secure pages through a URL like this:

https://your-domain-name/page.html

you will not have to take these steps. For more information on the steps needed to preserve your cookie data, please see the IC Tech. Ref. Document: Passing Cookie Data Through SSLServer.com

Related Items