///Site Statistics With Master Form V4

Site Statistics With Master Form V4

Site Statistics With Master Form V4

The latest version of Master Form V4 makes it easy to include environment variables in emails and databases. (It’s a free upgrade for those who already have a license. http://willmaster.com/mfv4 has a link to the generator.)

When you have a special campaign or project in place on your web site, 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 the information can be sent to the webmaster in one or more emails.

Information You Can Collect

Environment variables are such things as server type, browser used, cookies, IP address, and referring URL. Some servers will have certain environment variables available, others don’t. It varies.

To see which environment variables are available when a browser visits your site, use the “Environment variables” menu item in the Master Pre-Installation Tester control panel. Get the tester from http://willmaster.com/mpitsThe 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 the list provided by Master Pre-Installation Tester is available to Master Form V4. Later on, I’ll show you how to put those values into email and/or databases.

How it Works

JavaScript creates what’s referred to as an image object. This is an area in memory that can contain information about an image — which the browser can use if it needs to display the image.

When JavaScript created the image object, the area in memory is empty.

JavaScript will call Master Form V4 to provide image information for the image object.

When Master Form V4 is called to provide the image, it first updates databases and sends emails according to its instructions (see below). Only when it’s done with those chores, does it return an image to the calling JavaScript.

(The image Master Form V4 provides for the image object isn’t actually displayed. The image information is just stored in memory.)

The JavaScript may set a cookie before Master Form V4 is called. This cookie information can then be available to Master Form V4 for recording in email or database. (Cookies are less than ideal, but probably the best method available for tracking visitors from web page to web page.)

The JavaScript can also send along its own information when calling the Master Form V4 program. The example below sends the URL of the current web page.

A count of how many web pages have been viewed in the browser window, and a number indicating the visitor’s time zone, are examples of other information JavaScript can collect and sent to Master Form V4.

Master Form V4 can then use the information the JavaScript provided, in addition to the environment variables, when generating email and database record.

At the end of its run, Master Form V4 sends an image back to the JavaScript.

The JavaScript

When Master Form V4 is run, it expects certain information.

At a minimum, it requires the URL of what to display when it’s run ends (an image file, in this case). Other optional information are email and database template file locations.

Here is example of what can be done:

<script type="text/javascript" language="JavaScript">

<!-- Copyright 2005 Bontrager Connection, LLC
function LaunchMasterFormV4() {
// 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 = LaunchMasterFormV4;
//-->
</script>

If the JavaScript will set a cookie, it should be done before Master Form V4 is called.

NOTE: The cookie testing JavaScript code in the “Are Browser Cookies Enabled?” article found at http://willmaster.com/cancookie may be modified to set a cookie for tracking purposes. For tracking, it may be most useful to set a cookie only if none already exists.

The three-part “How to Use Cookies” article series linked from http://willmaster.com/archives has more information about cookies and how to use them.

In the JavaScript example above, the URL of the current page is sent to Master Form V4. As mentioned earlier, other information can also be collected and sent.

You’ll 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 Master Form V4 forms.

The file locations are exactly the same as they would be if specified in a form.

The “flowto” value 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 JavaScript to satisfy its request for information to put into the image object.

Notes About File and Email Templates

The templates in this system use placeholders just like all templates with by Master Form V4. The placeholder format is the field name between double square brackets. Master Form V4 then replaces the placeholders with the field’s value.

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

For example, the information about the URL of the current page in the JavaScript example is in a variable named URL. Thus, the [[URL]] placeholder can be used to insert the value the JavaScript provided.

Environment variables can be used in templates just like form fields can.

When you use the “Environment variables” menu item of Master Pre-Installation Tester (see above), the environment variable names will be all capital letters along the left side of the web page. Any or all of these names can be used in placeholders.

For example, if you want to log or receive an email with the contents of any cookies the browser might have available for that page, use placeholder [[HTTP_COOKIE]]

Viewing Tracking Data

From time to time, download the database file and import it into your spreadsheet or database program. The data can then be manipulated and analyzed 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.

2010-05-26T11:30:57+00:00 April 21st, 2005|JavaScript|0 Comments

About the Author:

Leave A Comment