LogData Method

 

The Enterprise Edition of BrowserHawk provides the ability to automatically gather statistics on your user’s browser capabilities and transmit them to the BrowserHawk Reports Web Service for storage in an Access or SQL Server database.

 

The BrowserHawk component communicates with the BrowserHawk Reports Web Service (BRWS) asynchronously so that there is no added delay or processing overhead incurred by your web scripts and web servers. This makes for extremely fast, efficient, and highly scalable stats collection and storage.

 

To communicate the results of a user's browser to the BRWS you call the LogData method.

 

Syntax:

bhObject.LogData [logType] [,userData1] [,userData2] [,userData3] [,userData4] [,userData5]

 

logType – Communication between the BrowserHawk ActiveX/COM component and the BRWS is handled via a hidden image tag embedded in the user's browser. By default, BrowserHawk will embed the appropriate tag into the browser's output stream at the time you call this method with no logType or a log type of 0 specified. If you specify a logType of 1, BrowserHawk does not insert this tag into the browser for you - instead it returns the tag as a string which you must then write into the browser's HTML output on your own.

 

userData1, userData2, userData3, userData4, userData5 – Set these optional parameter values you want stored in the database along with this particular user's browser statistics. This allows you to easily associate an important piece of information along with the statistics for the user. For example, you could pass in a user id or login name in this parameter. Then if the user reports a problem with your site to your support team, you can easily pull up their statistics and see exactly what their browser settings were at the time the error occurred. The values you pass in for these fields are stored in the corresponding userdata fields in the database. Note: userData1, userData2, and userData3 can be up to 255 characters in length each. Userdata4 and userData5 can be up to 50 characters in length each.

 

Note: Before using the LogData method you must configure this option using the BrowserHawk Editor->Special menu->Preference and Options->Reporting Options and Reports Database tabs, or you can set LogDataProperties instead.

 

Tip: You can use the LogDataProperties Property to specify the list of properties to log at run-time, as opposed to having LogData default to use the list of properties configured using the Reporting Options in the BrowserHawk Editor. This is handy for example if want to log different properties under different situations. For example you may want to only log different properties from different sections of your web site, or you may want to log a different property by browser type, etc.

 

Note: To record any of the extended properties (see GetExtPropertiesEx for a list) you must call the GetExtPropertiesEx method prior to calling the LogData method – otherwise BrowserHawk will log only the default values and not the browser's actual values.

 

Example:

 

Assume you used the BrowserHawk Editor to configure BrowserHawk to log the user's browser type, version, Flash plug-in information, and whether JavaScript is enabled. You then could use code such as this:

<%

Set bh = Server.CreateObject("cyScape.browserObj")

' Tell BH what properties we want to check

bh.SetExtProperties "plugin_flash,plugin_flashverex,javascriptenabled"

bh.GetExtPropertiesEx

%>

<html>

Your web page content goes here. BrowserHawk Reports has automatically recorded the statistics for this hit in the database at this point.

<% bh.LogData 'note that this must come before the </html> tag %>

</html>

 

Note: BrowserHawk Reports records a NULL value in the database for properties you did not configure it to track. For example, a value of 0 in the database for JavaScriptEnabled indicates the user had JavaScript disabled (1 indicates it was enabled). A value of NULL indicates that a value was not recorded because you did not request it to track this property.

 

IMPORANT TIP: You can use the BrowserHawk Editor to auto-generate the ASP, ASP.NET, ColdFusion MX, JSP, or servlet code needed to test the properties of interest and to call the LogData method to have the results inserted into your database. From the BrowserHawk Editor's main menu choose Special->Preferences and Options, then select the Reporting Options tab, and click on the Properties To Log button. Select the properties you are interested in logging in your database and press OK. Answer Yes when prompted if you'd like BrowserHawk to generate the scripting for you. The code in the example below was auto-generated by using this option.

 

See Also:

About BrowserHawk Reports

GetExtPropertiesEx Method

SetExtProperties Method

Reporting Options

Reports Database

LogDataProperties Property