burger menu icon
WillMaster

WillMaster > LibraryOur Software in Action >  >Master Form V4 in Action

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Site Statistics with Master Form V4

Using Environment Variables for Tracking and Gathering User Statistics

Master Form V4 has a very interesting feature; this versatile software can collect available "Environment Variables" that are available to the server.

When 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 Form V4 can be used to log generic information about site visitors in a CSV or other custom formatted plain text database. Such databases can be imported into office computer spreadsheet or database programs.

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 Form V4 can gather is different from server to server and browser to browser.

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 Form V4 as "placeholders". As an example, if you want to log or receive an email containing the contents of any cookies the browser might have available for that page, use placeholder [[HTTP_COOKIE]]

The statistic gathering procedure described in this article uses JavaScript to trigger 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 Master Form V4 to provide information for the image object.

The JavaScript can set a cookie before telling Master Form V4 to log visitor information. This cookie can then be logged as well.

Cookies are less than ideal, but probably the best method available for tracking visitors from web page to web page.

  1. 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 Master Form V4 to provide information for the image object.

  2. Master Form V4 then —
    1. Collects additional information as environment variables.

    2. 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.

    3. Optionally sends one or more emails with some or all of the information received from the JavaScript and/or the information it collected independently.

    4. 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 Form V4 that corresponds to information normally put into hidden form fields.

<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 Form V4 is called.

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 Form V4. Other information can also be collected and sent.

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 Form V4 ends its run, it will send that image file to the browser to satisfy the request for information to put into the image object the JavaScript created.

When Master Form V4 is done, information has been logged and the email has been sent.

Notes About File and Email Templates

The templates used in this system use placeholders just like all templates used by Master Form V4. The Placeholder format is the information name between double square brackets. Master Form V4 then replaces placeholders with the information value.

Any name=value pairs the JavaScript sends to Master Form V4 can be used in templates.

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 Form V4 independently gathers much information. What it can gather is different from server to server and browser to browser.

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 Form V4 will create another one when it needs to log information.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

Support Area – Ask Your Question Here

The "Code in articles help" forum at the Willmaster.com support area is the place to get information about implementing JavaScript and other software code found on Willmaster.com

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

Need Custom Software?
Click to
tell us about
your project.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2026 Will Bontrager Software LLC