Customizing a Full SAS Page Tag

Overview

All data elements to be tracked are stored in the browser’s memory before they are sent to the clickstream collection server. These data elements contain a key name, a value, and an enabled status. Only enabled keys have their values sent to the clickstream collection server. Tracking can be customized for each of the types of data that the page tag code is able to collect. This topic documents the procedure for the following elements:

Debug Mode

When you set up the initial tagging code, you can see the data that is sent to the clickstream collection server for a given page. This debug mode automatically scrolls to the top of the page. You can enable debug mode by simply inserting the line that includes SASTagDebug.js into the page tag code. For more information about this line, see Inserting a Full SAS Page Tag.
When accessed, pages containing this line invoke a pop-up window that displays the configuration settings for the tag, data elements as they are being captured, and the exact data request sent to the clickstream collection server. The debug mode window continues to update as actions such as link clicks and form-submit-button clicks are performed on the page. Note that there can be only one debug mode window open for a given browser.

Page Load Tracking

A page load event occurs anytime a page is loaded, refreshed, or returned to through the browser’s navigational buttons (forward or back). The occurrence of any of these actions always results in data collection. The data that is collected can be configured.
Page load events are tracked using the load instance identifier (LID), which must first be generated and collected by the JavaScript page tag code. The LID element is added to the set of data elements that is sent to the clickstream collection server as a column in Clickstream Page Tag Data Elements User Columns table: It is set to a random number between 1 and 100,000 and collected on load, click, and submit events, as follows:
Page Load Instance Identifier Characteristics
Event
Description
Action
Sample Value
Load
Can include initial load, return to a page via back or forward buttons, or page refresh
Generates new LID
65324
Click
Includes a click action on a tracked item such as a link
Collects LID value of the page hosting the clicked item
65324 (assuming that the item clicked upon is on the same page that generated the LOAD event)
Submit
Includes submission of a form
Collects LID of the page hosting the submitted form
65324 (assuming that the form is on the same page that generated the LOAD event)
The LID element is added to the set of data elements that is sent to the clickstream collection server as a column in Clickstream Page Tag Data Elements User Columns table: You can find this table in the Folders pane using the following path: Productsthen selectSAS Data Surveyor for Clickstream Datathen select2.2then selectTemplate Column Metadatathen selectClickstream Page Tag Data Elements User Columns.

Predefined Data Elements

Most of the predefined data elements have a value populated and are enabled for collection by default. Generally, predefined data element values should not be changed, unless an exception is documented. See SAS Page Tag Predefined Data Elements Reference.

User-Defined Data Elements

In cases where the predefined data elements do not provide enough information, user-defined data elements can be tracked. Code that tracks these data elements is added to either the st_siteDats() method in SASSiteConfig.js, or the st_pageDats() method in the full page tag code. Add the code to the former to track across multiple pages in your site or to the latter to track a data value for a specific page. For example, a content group value might be desired when several pages need to be classified as part of the same group of content. This value, if accessible from JavaScript, can easily be added to the set of data elements to track, as shown in the following code:
function st_siteDats()
{
   // Track a data value for all pages in this
   // site as "MarketingPages" since we
   // are dealing with our Marketing site.
   st_rq.dats.add("CONTENT_GROUP","MarketingPages",true,0x4 
      /*capture on page load only*/);
}
This example collects a new data value for all pages that include SASSiteConfig.js. Using an externally included configuration file such as SASSiteConfig.js enables you to avoid editing the tagging code on each page to make global changes across multiple pages. If, however, you would like to collect a data element for a specific page, such as the total on a shopping cart page, you can use the following page code:
function st_pageDats()
{
   // Track the shopping cart total for this page only
   st_rq.dats.add("CART_TOTAL",nTotal,true,0x1); /*capture on form submit only*/);
}
More information about the add() call can be found in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22. Look up “add” in the “Method Detail” section in the documentation for the ST_Dats class.

Meta Tag Tracking

By default, all meta tags on the page being accessed are tracked. Meta tag values are tracked by assigning an M_ prefix to the name of the meta tag. For example, a meta tag value of CATEGORY with a value of BOOK is tracked as the name/value pair M_CATEGORY=BOOK.
Meta tag tracking is configured by using the st_cfg.cap[‘M’] array element. For example, you can turn off meta tag tracking with the following code in either the st_siteCfg() or st_pageCfg() methods: st_cfg.cap['M']="0";. You can also capture only the meta tag named Author with the following code: st_cfg.cap['M']="0:Author";. For details about configuring meta tracking, see the documentation for the st_cfg.cap array element in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22.

Cookie Tracking

By default, all cookies for the page being accessed are tracked. Cookie values are tracked by assigning a C_ prefix to the name of the cookie. For example, a cookie named CART_ID with a value of 32567 is tracked as the name/value pair C_CART_ID=32567.
Cookie tracking is configured by using the st_cfg.cap[‘C’] array element. For example, you can turn off cookie capture with the following code in either st_siteCfg() or st_pageCfg(): st_cfg.cap['C']="0";. You can capture only chocolate, macadamia, and fudge cookies with the following code: st_cfg.cap['C']="0:chocolate,macadamia,fudge";. For details about configuring cookies tracking, see the documentation for the st_cfg.cap array element in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22.

Link Tracking

A link on a page is tracked if the SAS page tag configuration results in the collection of data when the link is clicked. Links are tracked based on the file type of the target of the link. By default, links to all file types are instrumented with the exception of the following: htm, html, asp, aspx, cfm, do, and php. These link types are exceptions because these pages can be tagged. Therefore, their content can be directly tracked.
Link instrumentation is configured by using the st_cfg.cap[‘L’] array element. The default setting of st_cfg.cap['L']=""; tracks every link on a page. However, you can change the link configuration in either st_siteCfg() or st_pageCfg()). For example, you can enter st_cfg.cap['L']="0"; to prevent the tracking of any links.
If you enable link tracking with st_cfg.cap['L']="";, you can also track specific types of links by configuring the st_trk element. See Configuring Link Tracking in Tagged Pages for detailed information. For details about configuring link tracking, see the documentation for the cap array element in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22.
You can also add code to enable and disable the stop-and-re-click behavior that stops the user's initial click, collects data, and then re-clicks. Use the st_trk() method to determine whether an item is tracked and instrumented for data collection, as follows:
function st_trk(o)	
 {
    switch(o.nodeName.toLowerCase())
 	  {
       case 'a':  // Link elements
          return true;
          break;
       default:
          return true;
    }
 }
If you do enable tracking with st_trk(), you can use the st_sar() method to control how data is collected. This method enables you to use your own programming logic to control the stop-and-re-click behavior on and off, as follows:
 function st_sar(o)	{
  switch(o.nodeName.toLowerCase())
  {
     case 'a':  // Link elements
        if ( o.href.indexOf('action=watch')>0  // MediaWiki watch/unwatch 
           button handling
          || o.href.indexOf('action=unwatch')>0)
           return false;
        else
           return true;
        break;
     default:
        return true;
  }
For details about configuring stop and re-click behavior, see the documentation for st_trk() and st_sar() in the “SASSiteConfig.js” section in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22.

Form Tracking

A form on a page is tracked if the SAS page tag configuration results in the collection of data when the user clicks a submit button on the form. Form element values are tracked by assigning an F prefix to the name of the form element. For example, a form element named FIRST_NAME with a value of John would be tracked as the name/value pair F_FIRST_NAME=John.
Form instrumentation is configured by using the st_cfg.cap[‘F’] array element. For example, you can turn off tracking for every form on a page by changing the form configuration in either st_siteCfg() or st_pageCfg() as follows: st_cfg.cap['F']="0"; In addition, you can enter the following code: st_cfg.cap['F']="1:1:formA,ccard,expdate:0:formB,fname,lname". This code tracks all of the forms on the page, but it (1) skips the elements named ccard and expdate in a form named formA and (2) captures only the elements named fname and lname in a form named formB. For details about configuring form tracking, see the documentation for the cap array element in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/clk22.
Note: Form content (other than password fields) is not captured by default. If forms on your site do collect sensitive information, then this data is collected from the form. Then it is transmitted using the protocol of the collection server (http or https) and stored in the collection server's log file. Make sure that form tracking is configured with this in mind and store only what is appropriate. This sensitive information includes, but is not limited to, credit card numbers, bank account numbers, and personally identifiable information. Also, access to the clickstream collection server's Web log file should be restricted to authorized users only.
For more information about the security aspects of form data capture, see Evaluating Security Issues for Form Capture.
The tracking of form data requires the page that contains the forms to be tagged. Data collection is performed on the following form elements:
Text fields
<INPUT type=”text">
Hidden fields
<INPUT type=”hidden">
Password fields
<INPUT type=”password"> Note that for password fields, the field name is collected, but the password value is not collected. A value of X is collected in place of the password. This setting is not configurable.
Text areas
<TEXTAREA>
Radio buttons
<INPUT type="radio">
Check boxes
<INPUT type="checkbox"> Check box data collection passes the value of each checked item, delimited by commas.
Note: As a general rule, if anything on a site requires the https protocol, then the site should use https for data collection. This precaution ensures that any sensitive information is transmitted securely.

Rich Internet Application Tracking

A rich Internet application is an embedded object within a Web page that typically has its own self-contained functionality that is separate from the main HTML in the page. An example of this is an embedded Flash object.
Generally, any embedded object can be tracked if the object meets the following criteria:
  • The object is programmable.
  • Tracking code can be inserted at the point of interest.
  • Calls to JavaScript can be made from the coding language of the object.
When these criteria are met, user actions within the rich Internet application can be tracked with the following JavaScript calls:
st_rq.dats.add("Name1","Value1",true,0x2 /* capture for click events only */);  
st_rq.dats.add("Name2","Value2",true,0x2 /* capture for click events only */);
st_rq.dats.add("Name3","Value3",true,0x2 /* capture for click events only */);
st_rq.send(st_rq.RQST_CLK,”click”);
These calls are documented in detail in the SAS Data Surveyor for Clickstream Data 2.2 Page Tagging JavaScript Reference at http://support.sas.com/rnd/gendoc/clickstream/22M1/en/. In particular, the call for add() is covered in the section for the ST_Val() class and the eFlags field name.
For example, you can track user clicks from ActionScript within a Flash object by creating a trackEvent function in the coding language of the rich Internet application. The following code was created in Flash:
function trackEvent(event:MouseEvent):Void {
     ExternalInterface.call("st_rq.dats.add","EVNT",event.target);
      ExternalInterface.call("st_rq.send");
  }
In this case, every mouse click passes an EVNT parameter and an indication of the user action that occurred.