Site Statistics with Master Form V4
Using Environment Variables for Tracking and Gathering User Statistics
MasterWhen you have a special campaign or project in place on your website, you want as much information about traffic and click-thrus as you can possibly glean.
Master
Alternately, or in addition to database storage, the information can be sent to the webmaster in one or more emails.
Types of Information Collected
The extent of the information Master
An indication of what may be gathered is obtained with Master Pre-Installation Tester using the "Environment Variables" menu option.
The environment variable names are all capital letters, each on a line by itself, followed by a colon character. The colon character is not part of the variable name.
The value of any environment variable on that list is available to Master
The statistic gathering procedure described in this article uses JavaScript to trigger Master
The JavaScript can set a cookie before telling Master
Cookies are less than ideal, but probably the best method available for tracking visitors from web page to web page.
-
JavaScript optionally sets a cookie, optionally collects information to be logged, and tells Master
Form V4 to run.The JavaScript tells Master
Form V4 to run by creating an image object (an area in computer memory that can hold details the browser would need to display an image), then calling MasterForm V4 to provide information for the image object. -
Master
Form V4 then -
Collects additional information as environment variables.
-
Optionally updates one or more database files with some or all of the information received from the JavaScript and/or the information it collected independently.
-
Optionally sends one or more emails with some or all of the information received from the JavaScript and/or the information it collected independently.
-
Sends an image to the browser.
-
The JavaScript
Following is example JavaScript. It can be put in the HEAD or the BODY area of the web page.
The JavaScript puts information into the URL used to call Master
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2005 Bontrager Connection, LLC
function LaunchCGIprogram() {
// optionally set cookie here.
var info = "URL=" + document.location.href;
info += "&emailtemplate=notifyemail.txt";
info += "&filetemplate=logfiletemplate.txt";
info += "&dbfile=logfile.csv";
info += "&flowto=http://example.com/image.gif";
var holder = new Image();
holder.src = "/cgi-bin/MasterFormV4.cgi?" + info;
}
window.onload = LaunchCGIprogram;
//-->
</script>
If the JavaScript will set a cookie, it should be done before Master
The cookie testing JavaScript in the "Testing for Cookies Enabled" article can be modified to set a cookie for tracking purposes. For tracking, it may be most useful to set a cookie only if none yet exists.
In the JavaScript above, the URL of the current page is part of the information to be sent to Master
You'll also notice information specifying the email template, the database file template, the database file name, and the URL of the custom thankyou page. The name=value pairs all correspond to hidden fields normally used in forms.
The file locations are exactly the same as they would be if specified in a form.
The "flowto" name is a little different than normally found in a form. In this case, the URL of the custom thankyou page is an http://... URL to an image file.
Before Master
When Master
Notes About File and Email Templates
The templates used in this system use placeholders just like all templates used by Master
Any name=value pairs the JavaScript sends to Master
For example, the information about the URL of the current page is held by a variable named URL. Thus, the [[URL]] placeholder will be replaced with the value the JavaScript provided.
Master
As indicated above, information about what is gathered can be obtained by using Master Pre-Installation Tester and the "Environment Variables" menu option. On the resulting page, environment variable names are all capital letters, each on a line by itself, followed by a colon character. The colon character is not part of the variable name.
The value of any environment variable on that list can be logged or sent in email.
Tracking
From time to time, download the database file and import it into your spreadsheet or database program. The data can then be manipulated according to the abilities of your software.
If you rename or delete the database file from the server, Master
Will Bontrager

