//********************************************************************
//
// Copyright (c) 2002-2008 MindLab GmbH
// All rights reserved.
//
//====================================================================
//
// Project : netmind
// Filename : nm_tr_combined.js
//
//====================================================================
//
/**
* @file
* This script can be used to implement a pixeltracking on your website
*
* @author $Felix Engemann$
* @version $Name: V2_5_1 $
* @date $Date: 2009-07-01 08:36:31 $
*@listofchanges cha adaption for postbank help-div 2007/09/07
*@listofchanges cha adaption for postbank clientStat tracking Pixelhelp-div 2007/11/13
*@listofchanges cha adaption for postbank clientStat tracking Pixelhelp-div 2007/11/16
*@listofchanges asc generalisation for netmind 4.0 release 2007/12/10
$Log: nm_tr_combined.js,v $
Revision 1.7 2009-07-01 08:36:31 pohl
Updated documentation, combined and minimized versions of the scripts
Revision 1.6 2009-04-28 09:04:23 pohl
Added HTTP POST functionallity
Added JSON encoding
Revision 1.10 2009-04-27 13:53:01 pohl
Added HTTP POST functionallity
Added JSON encoding
Revision 1.9 2009-01-21 12:33:18 pohl
Added techinfo parameters nm_javascript and changed parameter nm_cookies to nm_cookie.
Added functionallity to test/debug pixel tracking by logging configuration and request values to separate window.
Revision 1.8 2008-12-02 14:18:41 pohl
Added configuration options to enable/disable individual tech plugin detection
Revision 1.7 2008/09/09 12:03:48 pohl
Fixes/improvements for SID timestamp handling
Revision 1.6 2008/09/08 14:31:01 pohl
Added method setParameter
Revision 1.5 2008/09/03 13:33:57 pohl
Added new logic to inject a netmind SID via URL parameter.
*/
//********************************************************************
//config Object
//********************************************************************
function cConfigPixel()
{
//-----------------------------------------------------
// members
//-----------------------------------------------------
//true = Tracker uses Cookies
//false= tracker uses Session IDs in Urls
this.m_bCookieTracking = true;
// true = Use content side tracking.
// The nm_track.js script needs to be available on the
// tracked web server and the m_strPixelJSPath value needs
// to be set accordingly.
// false = Use tracker side tracking.
// The scripts nm_tr_config, nm_tr_remote.js and the image
// nm_track.gif need to be available on the tracked web server
// and the m_strPixelPath value needs to be set accordingly.
this.m_bContentSideTracking = false;
// Session timeout for tracker side tracking without tracker cookies.
// we will treat a session as timed out if more than this amount
// of seconds has passed between two clicks
this.m_nNetMindSessionTimeout = 1800;
//set to true, if you want to get the params automatically
this.m_bAutoparams = true;
//set to true, if you want to send the pixel automatically
this.m_bAutosend = true;
//The protocol to use for getting the pixel, could be either http
//or https
this.m_strPixelProtocol = location.href.substr(0, location.href.indexOf(":"));
//the servername to get the pixel from (no protocol here, and
//no path here), you can append a port or prepend an authendication
//like: user:passwort@myserver.mydomain.com:12345
//where "user:password@" is the authentication
// "myserver.mydomain.com" is the fully qualified servername
// ":12345" is a port-Number
// this.m_strPixelServer = "nmt01.dus.dg-i.net";
this.m_strPixelServer = "pc.peterhahn.de";
//the path to request from the given server, this path could of
//course include CGI-Parameters
//example: "/mywebbug?thisismyparameter=value"
this.m_strPixelJSPath = "/nm_track.js?nm.customer.id=peterhahn";
this.m_strPixelPath = "/nm_track.gif?nm.customer.id=peterhahn";
// this value defines CGI parameter to inject the SID from outside.
this.m_strSIDParam = "nmsid";
// this flag allows to explicitly disable SID injection via CGI parameters
this.m_bSIDParamDisabled = false;
//Send Url by default
this.m_bSendUrl = true;
//Send Referrer by default
this.m_bSendReferrer = true;
//Send MetaTags by default
this.m_bSendMetaTags = true;
//Send Browser Setting, Screen Infos etc.
this.m_bSendTech = true;
//Send Browser Setting, Screen Infos etc.
this.m_bSendUrlHash = false;
//Send CGI Params of the current location as Parameters of the Pixel
this.m_bSendCGIParams = false;
//Indicates whether an HTTP POST request (using the XMLHttpRequest class)
//should be used
this.m_bUseHttpPost = false;
//Indicates whether object parameters should be converted to a
//JSON-repesentation before sending it
this.m_bConvertToJSON = false;
//to workaround problems with IE and unclosed DOM objects (body),
//the ID of an existing dummy HTML element to receive the
//temporary DOM objects can be specified here.
this.m_strPostParentId = false;
//--------------------------------------------------------
// metatags to be parsed
//--------------------------------------------------------
this.m_aMetatag = new Array(
"nm.*"
);
//--------------------------------------------------------
// Hashed parameter to be parsed
//--------------------------------------------------------
this.m_aHashParameter = new Array(
"test",
"key"
);
this.m_oTechPlugins = new Object();
this.m_oTechPlugins['Director'] = false;
this.m_oTechPlugins['MediaPlayer'] = false;
this.m_oTechPlugins['Flash'] = false;
this.m_oTechPlugins['RealPlayer'] = false;
this.m_oTechPlugins['AcroRead'] = false;
// flag to enable debugging.
// if enabled, a window is opened, displaying the pixel configuration and the
// pixel request for each request.
this.m_bDebug = false;
} // end class cConfigPixel
//==========================================================
// getAutoParams
//==========================================================
function config_getSendUrlHash () {
return this.m_bSendUrlHash;
}
//==========================================================
// getAutoParams
//==========================================================
function config_getAutoParams () {
return this.m_bAutoparams;
}
//==========================================================
// getAutoSend
//==========================================================
function config_getAutoSend () {
return this.m_bAutosend;
}
//==========================================================
// getSendUrl
//==========================================================
function config_getSendUrl () {
return this.m_bSendUrl;
}
//==========================================================
// getSendReferrer
//==========================================================
function config_getSendReferrer () {
return this.m_bSendReferrer;
}
//==========================================================
// getSendMetatags
//==========================================================
function config_getSendMetatags () {
return this.m_bSendMetaTags;
}
//==========================================================
// getSendTech
//==========================================================
function config_getSendTech () {
return this.m_bSendTech;
}
//==========================================================
// getSendTechPlugin
// strPlugin = 'Director', 'MediaPlayer', 'Flash',
// 'RealPlayer', 'AcroRead'
//==========================================================
function config_getSendTechPlugin( strPlugin )
{
if ( this.m_oTechPlugins )
{
return this.m_oTechPlugins[strPlugin];
}
return false;
}
//==========================================================
// getSendCGIParams
//==========================================================
function config_getSendCGIParams () {
return this.m_bSendCGIParams;
}
//==========================================================
// getPixelUrl
//
// return the URL to the tracking pixel or script.
//==========================================================
function config_getPixelUrl () {
return this.m_strPixelProtocol+"://"+this.m_strPixelServer + this.getPixelPath();
}
//==========================================================
// getProtocol
//==========================================================
function config_getProtocol () {
return this.m_strPixelProtocol;
}
//==========================================================
// getPixelServer
//==========================================================
function config_getPixelServer () {
return this.m_strPixelServer;
}
//==========================================================
// getPixelPath
//==========================================================
function config_getPixelPath () {
if (this.m_bContentSideTracking)
{
return this.m_strPixelJSPath;
}
else
{
return this.m_strPixelPath;
}
}
//==========================================================
// getSIDParam
//==========================================================
function config_getSIDParam () {
return this.m_strSIDParam;
}
//==========================================================
// getSIDParamDisabled
//==========================================================
function config_getSIDParamDisabled () {
return this.m_bSIDParamDisabled;
}
//==========================================================
// isCookieTracking
//==========================================================
function config_isCookieTracking () {
return this.m_bCookieTracking;
}
//==========================================================
// isContentSideTracking
//==========================================================
function config_isContentSideTracking () {
return this.m_bContentSideTracking;
}
//==========================================================
// getSessionTimeout
//==========================================================
function config_getSessionTimeout () {
return this.m_nNetMindSessionTimeout;
}
//==========================================================
// isHttpPostEnabled
//==========================================================
function config_isHttpPostEnabled()
{
return this.m_bUseHttpPost;
}
//==========================================================
// isJSONEnabled
// returns whether to use JSON encoding for object
// values.
// Returns only true, if m_bConvertToJSON is set AND
// the JSON object is available.
//==========================================================
function config_isJSONEnabled()
{
return ( typeof(JSON) == 'object'
&& this.m_bConvertToJSON );
}
//==========================================================
//Definition of Prototypes
//==========================================================
//methoden zur Klasse hinzufuegen
cConfigPixel.prototype.isCookieTracking = config_isCookieTracking;
cConfigPixel.prototype.isContentSideTracking = config_isContentSideTracking;
cConfigPixel.prototype.getPixelUrl = config_getPixelUrl;
cConfigPixel.prototype.getProtocol = config_getProtocol;
cConfigPixel.prototype.getPixelServer = config_getPixelServer;
cConfigPixel.prototype.getPixelPath = config_getPixelPath;
cConfigPixel.prototype.getSIDParam = config_getSIDParam;
cConfigPixel.prototype.getSIDParamDisabled = config_getSIDParamDisabled;
cConfigPixel.prototype.getAutoParams = config_getAutoParams;
cConfigPixel.prototype.getAutoSend = config_getAutoSend;
cConfigPixel.prototype.getSendUrl = config_getSendUrl;
cConfigPixel.prototype.getSendUrlHash = config_getSendUrlHash;
cConfigPixel.prototype.getSendReferrer = config_getSendReferrer;
cConfigPixel.prototype.getSendMetatags = config_getSendMetatags;
cConfigPixel.prototype.getSendTech = config_getSendTech;
cConfigPixel.prototype.getSendTechPlugin = config_getSendTechPlugin;
cConfigPixel.prototype.getSendCGIParams = config_getSendCGIParams;
cConfigPixel.prototype.getSessionTimeout = config_getSessionTimeout;
cConfigPixel.prototype.isHttpPostEnabled = config_isHttpPostEnabled;
cConfigPixel.prototype.isJSONEnabled = config_isJSONEnabled;
//********************************************************************
//Session-Management
//********************************************************************
//********************************************************************
//Session-Object
//********************************************************************
//==========================================================
//Constructor for Session-Object
//==========================================================
function cRemoteSession( oConfig )
{
//-----------------------------------------------------
// members
//-----------------------------------------------------
//this is the SessionID returned at the end
this.m_strNetMindSID = "";
this.m_oConfig = oConfig;
// flag indicating whether to use the injected SID from the CGI parameter
// or whether to use the more recent SID provided by the tracker
// via cookie or URI replacement
this.m_bCgiSIDHandled = false;
// remember pixel time initialization
// needed to adjust timestamp for subsequent JS pixel requests
// when using injected SID.
this.nPixelTime = new Date().getTime() / 1000;
}//end function cRemoteSession()
//==========================================================
//method for object Session: returns the Session ID
//==========================================================
function remotesession_getSessionID()
{
var strNetMindSID = "";
// get cookie string
var strCookie = document.cookie
//split into cookies
var arCookies = strCookie.split("; ");
//loop through cookies and get NetMind-Cookie
var nLoopCount = 0;
var strActCookieName = "";
if ( strNetMindSID == "" )
{
while (nLoopCount < arCookies.length) {
var strActCookie = arCookies[nLoopCount];
var arActCookie = strActCookie.split("=");
var strActCookieName = arActCookie[0];
if (strActCookieName == "NETMIND_SID") {
strNetMindSID = arActCookie[1];
}
nLoopCount++;
}//end while ((strActCookieName != "NETMIND_SID") && (nLoopCount < arCookies.length))
if (!oNMConfig.isContentSideTracking() && !oNMConfig.isCookieTracking())
{
//
// tracker-side tracking with URL rewriting.
// SID should be set in the following variable:
//
var strSID_trackerside="/";
var strNewSID = "";
var nNewTS = 0;
if (strSID_trackerside != "/") {
strNewSID = strSID_trackerside.substr (6, 54);
nNewTS = parseInt(
String(parseInt( strNewSID.substring(44) )
+ (new Date().getTime() / 1000 - this.nPixelTime)));
}
// check whether session from cookie is still valid:
if (strNetMindSID != "" && strNewSID != "" )
{
var nOldTS = parseInt( strNetMindSID.substr(44) );
if ( nOldTS <= nNewTS )
{
// cookie session did not exceed timeout,
// use cookie and update timestamp of SID
if ( this.m_bCgiSIDHandled )
{
// use netmind SID from cookie, set via CGI param
strNetMindSID = strNetMindSID.substr(0,43) + "-" + nNewTS;
}
else
{
// use netmind SID provided by the tracker
strNetMindSID = strNewSID.substr(0,43) + "-" + nNewTS;
}
}
else
{
strNetMindSID = strNewSID;
}
} else {
// no SID from cookie, use new SID if available
strNetMindSID = strNewSID;
}
if ( strNetMindSID != "")
{
document.cookie = "NETMIND_SID="+strNetMindSID+"; path=/";
}
}
}
strCgiSID = this.getCGISessionID();
if ( strCgiSID != null )
{
strNetMindSID = strCgiSID;
document.cookie = "NETMIND_SID="+strNetMindSID+"; path=/";
}
this.m_strNetMindSID = strNetMindSID;
return this.m_strNetMindSID;
}//end function session_getSessionID()
//==========================================================
// getCGISessionID()
// extract the session ID injected via CGI parameter.
// returns null if no such parameter, or disabled, or if
// already handled, i.e. the injected SID is available
// as cookie.
//==========================================================
function remotesession_getCGISessionID()
{
if ( this.m_bCgiSIDHandled )
{
// remote CGI SID already extracted. Must be available in the cookies.
return null;
}
if ( !this.m_oConfig.getSIDParamDisabled || !this.m_oConfig.getSIDParamDisabled() )
{
var strSIDParam = "nmsid";
if ( this.m_oConfig.getSIDParam )
{
strSIDParam = this.m_oConfig.getSIDParam();
}
if ( strSIDParam )
{
this.m_bCgiSIDHandled = true;
var strCgiSID = remotepixel_extractCGIParam( strSIDParam );
if ( strCgiSID == "" )
{
return null;
}
return strCgiSID;
}
}
return null;
} // end function remotesession_getCGISessionID
//==========================================================
//add methods to class cSession
//==========================================================
cRemoteSession.prototype.getSessionID = remotesession_getSessionID;
cRemoteSession.prototype.getCGISessionID = remotesession_getCGISessionID;
//********************************************************************
//Pixel-Object
//********************************************************************
//Contstructor for Pixel-Object
function cRemotePixel(oConfig)
{
//-----------------------------------------------------
// members
//-----------------------------------------------------
//pixel object constructor
this.m_arParameterList = new Array();
this.m_nParameterCount = 0;
//Configuration
this.m_oConfig = oConfig;
this.m_strPixelURL = oConfig.getPixelUrl();
this.m_strPixelURLPrefix = oConfig.getProtocol()+"://"+oConfig.getPixelServer() + "/";
this.m_strPixelURLSuffix = "";
var strPixelpath = oConfig.getPixelPath();
if (strPixelpath.charAt(0) == "/")
{
this.m_strPixelURLSuffix = strPixelpath.substr(1);
} else {
this.m_strPixelURLSuffix = strPixelpath;
}//end else (PixelPath.charAt(0) == "/")
if ( oConfig.m_bDebug )
{
this.m_oDbgWin = window.open( "", "PixelDebug", "height=550,dependent=yes,scrollbars=yes,resizable=yes" );
if ( !this.m_oDbgWin.document.getElementById('_log_config') )
{
this.m_oDbgWin.document.write( "
PixelDebugConfig values:
Tracked values:
" );
this.writeConfig( true );
}
else
{
this.writeConfig( false );
}
}
this.m_oIFrame = null;
this.m_oBody = null;
}//end function cRemotePixel()
function remotepixel_writeConfig( bAppend )
{
var oConfig = this.m_oConfig;
this.writeDebug( document.URL, "_log_config", bAppend, true );
if ( oConfig.m_bDebug )
{
if ( oConfig.isCookieTracking() )
{
this.writeDebug( "Cookie Tracking enabled", "_log_config", true );
}
else
{
this.writeDebug( "URL rewriting enabled
", "_log_config", true );
}
if ( oConfig.isContentSideTracking() )
{
this.writeDebug( "Contentside Tracking enabled", "_log_config", true );
}
else
{
this.writeDebug( "Trackerside Tracking enabled", "_log_config", true );
}
if ( oConfig.isHttpPostEnabled() )
{
this.writeDebug( "HTTP POST enabled", "_log_config", true );
}
else
{
this.writeDebug( "HTTP GET enabled", "_log_config", true );
}
this.writeDebug( "Netmind Session Timeout: " + oConfig.m_nNetMindSessionTimeout, "_log_config", true );
this.writeDebug( "Autoparams: " + oConfig.m_bAutoparams, "_log_config", true );
this.writeDebug( "Autosend: " + oConfig.m_bAutosend, "_log_config", true );
this.writeDebug( "Send URL: " + oConfig.m_bSendUrl, "_log_config", true );
this.writeDebug( "Send Referrer: " + oConfig.m_bSendReferrer, "_log_config", true );
this.writeDebug( "Send MetaTags: " + oConfig.m_bSendMetaTags, "_log_config", true );
this.writeDebug( "Send TechInfo: " + oConfig.m_bSendTech, "_log_config", true );
this.writeDebug( "Send Url Hash: " + oConfig.m_bSendUrlHash, "_log_config", true );
this.writeDebug( "Send CGI-Params: " + oConfig.m_bSendCGIParams, "_log_config", true );
this.writeDebug( "Plugins to check:", "_log_config", true );
}
}
//==========================================================
// Wenn der Debugging-Mode aktiviert wurde
// (cConfigPixel.m_bDebug), wird der angegebene String im
// Debug-Fenster ausgegeben.
//==========================================================
function remotepixel_writeDebug( strDebug, strElementId, bAppend, bBold )
{
var oElem = null;
if ( this.m_oDbgWin )
{
if ( strElementId )
{
oElem = this.m_oDbgWin.document.getElementById( strElementId );
}
if ( !oElem )
{
oElem = this.m_oDbgWin.document.getElementsByTagName( "body" )[0];
}
if ( oElem )
{
if ( !bAppend )
{
oElem.nodeValue = "";
}
if ( bBold )
{
var oBold = this.m_oDbgWin.document.createElement("b");
oElem.appendChild( oBold );
oElem = oBold;
}
var oTextNode = this.m_oDbgWin.document.createTextNode( strDebug );
oElem.appendChild( oTextNode );
oElem.appendChild( this.m_oDbgWin.document.createElement("br") );
}
}
}
//==========================================================
// Method to convert the given value to a valid
// representation.
// Normally this method just returns the given value except:
// * the value is of type object
// * the JSON object is available
// * and JSON is enabled in the config
//==========================================================
function remotepixel_convertValue(value)
{
if ( oNMConfig.isJSONEnabled()
&& typeof(value) == 'object' )
{
return JSON.stringify(value);
}
return value;
}
//==========================================================
//methode fuer Objekt Pixel: Fuegt einen Parameter hinzu
//==========================================================
function remotepixel_addParameter(key, value)
{
arPair = new Array(key, this.convertValue( value) );
this.m_arParameterList[this.m_nParameterCount] = arPair;
this.m_nParameterCount++;
}//end function pixel_add_parameter()
//==========================================================
// methode fuer Objekt Pixel: setzt einen Parameter.
// wurde der Parameter bereits gesetzt, so wird er mit dem
// neuen Wert ersetzt.
//==========================================================
function remotepixel_setParameter(key, value)
{
var arPair = new Array( key, this.convertValue( value ) );
var arExist;
var nIdx;
var bFound = false;
for ( nIdx = 0; nIdx < this.m_nParameterCount; nIdx ++ )
{
arExist = this.m_arParameterList[nIdx];
if ( arExist[0] == arPair[0] )
{
// parameter already set, replace with new value
bFound = true;
this.m_arParameterList[nIdx] = arPair;
break;
}
}
if ( !bFound )
{
// add new parameter:
this.m_arParameterList[this.m_nParameterCount] = arPair;
this.m_nParameterCount++;
}
}
//==========================================================
//method for object Pixel: add affiliate
//==========================================================
function remotepixel_addAffiliate(name)
{
this.addParameter("affiliate", name);
this.writeDebug( "affiliate = '" + affiliate + "'", "_log_values", true );
}//end function remotepixel_addAffiliate(name)
//==========================================================
//method for object Pixel: add url
//
//
// Customization
// cha - 25.06.2008 - Cgi Paramter des aktuellen URI werden automatisiert als Paramter angehängt.
//
//==========================================================
function remotepixel_addUrl()
{
var strUrlParam = document.URL;
this.addParameter("url", strUrlParam);
this.writeDebug( "url = '" + strUrlParam + "'", "_log_values", true );
}//end function remotepixel_addAffiliate(name)
//==========================================================
//method for object Pixel: add referrer
//==========================================================
function remotepixel_addReferrer()
{
this.addParameter("referrer", document.referrer);
this.writeDebug( "referer = '" + document.referrer + "'", "_log_values", true );
}//end function remotepixel_addAffiliate(name)
//==========================================================
//method for object Pixel: add parameter to URL
//==========================================================
function remotepixel_addParamToUrl(strUrl, arParameterList)
{
if (strUrl.indexOf ("?") == -1)
{
strUrl = strUrl + "?";
}
else
{
strUrl = strUrl + "&";
}
for(var i=0; i0) strUrl += "&";
strUrl += escape(arParameterList[i][0])+"="+escape(arParameterList[i][1]);
}//end for(i=0; i' );
}
catch (e)
{
this.m_oIFrame = document.createElement( "iframe" );
}
this.m_oIFrame.style.display = "none";
this.m_oIFrame.name = "nm_postframe";
this.m_oBody.appendChild( this.m_oIFrame );
}
if ( this.m_oPostDiv )
{
delete this.m_oPostDiv;
}
oDiv.style.display = "none";
this.m_oBody.appendChild( oDiv );
oForm = document.createElement("form");
oForm.action = strTargetUrl;
oForm.method = 'post';
oForm.target = 'nm_postframe';
oDiv.appendChild( oForm );
this.m_oPostDiv = oDiv;
return oForm;
}
//==========================================================
// Generate an XML HTTP instance (if supported).
// If not supported, null is returned.
//==========================================================
function remotepixel_getXmlHttpInstance()
{
var oXmlHttp = null;
if ( typeof XMLHttpRequest != 'undefined' )
{
oXmlHttp = new XMLHttpRequest();
}
if ( !oXmlHttp )
{
try
{
oXmlHttp = new ActiveXObject( 'Msxml2.XMLHTTP' );
}
catch(e)
{
try
{
oXmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
}
catch(e)
{
oXmlHttp = null;
}
}
}
return oXmlHttp;
}
//==========================================================
// Send the pixel data via as XML HTTP request via HTTP post
//==========================================================
function remotepixel_postData(oRemoteSession)
{
var bCookieTracking = this.m_oConfig.isCookieTracking();
var bContentSideTracking = this.m_oConfig.isContentSideTracking();
var strSID = oRemoteSession.getSessionID();
var strCgiSID = oRemoteSession.getCGISessionID();
var strUrl;
var nParam;
var oForm;
if ( strCgiSID )
{
strSID = strCgiSID;
}
if (bCookieTracking) {
//-----------------------------------------------------
// Cookie Tracking Variante
// no difference between content side and tracker side
//-----------------------------------------------------
strUrl = this.m_strPixelURL;
} else {
if (strSID != "" ) {
strSID = "-snm-" + strSID + "-enm-";
}
strUrl = this.m_strPixelURLPrefix+strSID+this.m_strPixelURLSuffix;
} // end else if (bCookieTracking)
this.writeDebug( "postData: sending request to " + strUrl, "_log_values",
true, false );
if ( 0 ) {
try
{
// async POST request
// but we will not handle any errors, so we won't register a
// state-change callback
oHttpRequest.open('POST', strUrl, true );
oHttpRequest.setRequestHeader( "Content-Type",
"application/x-www-form-urlencoded" );
// construct POST body
var strPostBody = "";
var strAmp = "";
for ( nParam = 0; nParam < this.m_arParameterList.length; nParam ++ )
{
strPostBody += strAmp + escape( this.m_arParameterList[nParam][0] )
+ "=" + escape( this.m_arParameterList[nParam][1] );
strAmp = "&";
}
// and send and forget:
oHttpRequest.send( strPostBody );
}
catch( e )
{
this.writeDebug( 'Could not send POST request: ' + e, '_log_values',
true, true );
if ( oNMConfig.isGetFallbackEnabled() )
{
this.sendData( oRemoteSession );
}
}
} else {
oForm = this.getHiddenForm( strUrl );
this.populateForm( oForm );
oForm.submit();
}
}
//==========================================================
// populateForm
// Populate the hidden POST form with the values from the
// pixel instance.
//==========================================================
function remotepixel_populateForm( oForm )
{
var strSID = oNMRemoteSession.getSessionID();
var strCgiSID = oNMRemoteSession.getCGISessionID();
var bCookieTracking = this.m_oConfig.isCookieTracking();
var bContentSideTracking = this.m_oConfig.isContentSideTracking();
var nParam;
var oField;
for ( nParam = 0; nParam < this.m_arParameterList.length; nParam ++ )
{
oField = document.createElement( 'input' );
oField.type = 'hidden';
oField.name = this.m_arParameterList[nParam][0];
oField.value = this.m_arParameterList[nParam][1];
oForm.appendChild( oField );
}
}
//==========================================================
//methode fuer Objekt Pixel: senden des Pixels
//==========================================================
function remotepixel_sendData(oRemoteSession)
{
if ( this.m_oConfig.isHttpPostEnabled() )
{
// POST enabled, use the appropriate method
this.postData( oRemoteSession );
return;
}
var bCookieTracking = this.m_oConfig.isCookieTracking();
var bContentSideTracking = this.m_oConfig.isContentSideTracking();
if (bCookieTracking) {
//-----------------------------------------------------
// Cookie Tracking Variante
// no difference between content side and tracker side
//-----------------------------------------------------
var strCgiSID = oRemoteSession.getCGISessionID();
if ( strCgiSID )
{
// need to set cookie
var strPixelServer = this.m_oConfig.getPixelServer();
var strHost = strPixelServer.split(':')[0];
// set the cookie specifically for the pixel server
var strInjectedCookie = 'NETMIND_SID='+strCgiSID+'; path=/; domain='+strHost;
document.cookie = strInjectedCookie;
}
var strUrl = this.m_strPixelURL;
strUrl = remotepixel_addParamToUrl(strUrl,this.m_arParameterList);
this.writeDebug( "Sending Image-Request: '" + strUrl + "'", "_log_values", true );
var oTrackingImg = new Image();
oTrackingImg.src = strUrl;
} else {
var strSID = oRemoteSession.getSessionID();
if (strSID != "" ) {
strSID = "-snm-" + strSID + "-enm-";
}
var strUrl = this.m_strPixelURLPrefix+strSID+this.m_strPixelURLSuffix;
strUrl = remotepixel_addParamToUrl(strUrl,this.m_arParameterList);
if ( bContentSideTracking )
{
var oHead = document.getElementsByTagName("head")[0];
var aSidScript = document.getElementById ('sidscript');
if (aSidScript) { // Already exists
for (var j = 0; j < aSidScript.length; j++) {
oHead.removeChild(aSidScript[j]);
}//end for (var j = 0; j < aMetatag.length; j++)
}
// need a script element to load the JS
oScript = document.createElement('script');
oScript.id = 'sidscript';
oScript.type = 'text/javascript';
oScript.src = strUrl;
//-----------------------------------------------------
// Set an Evant Handler to Set the Valid Variable and
// the SessionID
//-----------------------------------------------------
//oScript.addEventListener('load',remotepixel_setCookie,false);
oHead.appendChild(oScript);
}
else
{
// just use an image tag. SID has already been set when loading this script.
var oTrackingImg = new Image();
oTrackingImg.src = strUrl;
}
} // end else if (bCookieTracking)
}//end function remotepixel_sendData()
//==========================================================
//method setSidReady
//==========================================================
function remotepixel_setCookie()
{
//alert ("remotepixel_setCookie");
//-----------------------------------------------------
// this function is used as an event Handler
// for the loading of the SID containing Javascript
// the function does nothing but checking the
// Javascript Variable containing the
//-----------------------------------------------------
}//end function remotesession_waitSidReady()
//==========================================================
//methode fuer Objekt Pixel: auslesen der techdaten
//==========================================================
function remotepixel_getTechData () {
//--------------------------------------------------------
// variables for general settings
//--------------------------------------------------------
var javaOK = "unknown";
var cookiesOK = "unknown";
var browsLang = "unknown";
var availheight = screen.availHeight;
var availwidth = screen.availWidth;
var colordepth = screen.colorDepth + " bit";
var height = screen.height;
var width = screen.width;
var title = document.title;
this.writeDebug( "TechInfo:", "_log_values", true, true );
var agt = navigator.userAgent.toLowerCase();
var ie = (agt.indexOf("msie") != -1);
var ie7 = false;
//accept only higher than MSIE 4
//otherwise the detectIE() function would not work
if(ie) {
ie = (agt.indexOf("msie 4") == -1) && (agt.indexOf("msie 3") == -1);
ie7 = (agt.indexOf("msie 7") > -1);
}//end if(ie)
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
//--------------------------------------------------------
// Java and Cookies
//--------------------------------------------------------
if (navigator.javaEnabled()==true){javaOK="yes";}else{javaOK="no";}
this.writeDebug( "java = " + javaOK, "_log_values", true );
//--------------------------------------------------------
//-- cookieEnabled only works in MSIE.
//--------------------------------------------------------
if ((navigator.cookieEnabled) && (navigator.cookieEnabled==true)) {cookiesOK="yes";} else {cookiesOK="no";}
this.writeDebug( "cookies = " + cookiesOK, "_log_values", true );
//--------------------------------------------------------
// language
//--------------------------------------------------------
if (navigator.language)
browsLang = navigator.language;
this.writeDebug( "language = " + browsLang, "_log_values", true );
this.writeDebug( "screen = " + width + "x" + height, "_log_values", true );
this.writeDebug( "colordepth = " + colordepth, "_log_values", true );
this.writeDebug( "title = " + title, "_log_values", true );
this.writeDebug( "javascript = yes", "_log_values", true );
//save paramters into pixel
this.addParameter("nm_java", javaOK);
this.addParameter("nm_cookie", cookiesOK);
this.addParameter("nm_screen", width + "x" + height);
this.addParameter("nm_colordepth", colordepth);
this.addParameter("nm_title", title);
this.addParameter("nm_javascript", "yes" );
}//end function pixel_getTechData ()
//==========================================================
//methode zum Auslesen der metatags
//==========================================================
// setzen eines leeren Metatags auf "-"
function remotepixel_getMetaTags () {
var aMetatag = this.m_oConfig.m_aMetatag;
//Save metatags to track into pixel-parameter-list. validation with regexp match
var strMetaTags = "";
for (var i = 0; i < document.getElementsByTagName('meta').length; i++) {
for (var j = 0; j < aMetatag.length; j++) {
var re = new RegExp(WildToReg(aMetatag[j]));
if (document.getElementsByTagName('meta')[i].getAttribute('name')) {
if ( document.getElementsByTagName('meta')[i].getAttribute('name').match(re) ) {
if (document.getElementsByTagName('meta')[i].getAttribute('content'))
this.addParameter(document.getElementsByTagName('meta')[i].getAttribute('name'), document.getElementsByTagName('meta')[i].getAttribute('content'));
else
this.addParameter(document.getElementsByTagName('meta')[i].getAttribute('name'), "-");
} // end if document.getElementsByTagName('meta')[i].getAttribute('name').match(re
} // end if (document.getElementsByTagName('meta')[i].getAttribute('name'))
}//end for (var j = 0; j < aMetatag.length; j++)
}//end for (var i = 0; i < document.getElementsByTagName('meta').length; i++)
}// end method remotepixel_getMetaTag
//==========================================================
//methode zum Auslesen der per Hash angehängten Parameter
//==========================================================
// setzen eines leeren Hashparameter auf "-"
function remotepixel_getHashParameter () {
var aParamList = this.m_oConfig.m_aHashParameter;
var strLoc=(document.location+"");
var nPos=strLoc.indexOf("#");
if (nPos != -1) {
var strHashQs=strLoc.substring(nPos+1, strLoc.length);
aParams = remotepixel_SplitParams(strHashQs);
//Save metatags to track into pixel-parameter-list. validation with regexp match
var strHashParam = "";
for (var j = 0; j < aParamList.length; j++) {
if ( aParams[aParamList[j]] ) {
this.addParameter(aParamList[j],aParams[aParamList[j]]);
} // end if( aParams[aParamList[j]] )
}//end for (var j = 0; j < aMetatag.length; j++)
} // end if nPos != -1)
}// end method remotepixel_getHashParameter
//==========================================================
//methode zum Auslesen der GET CGI Paramter
//==========================================================
// setzen eines leeren Hashparameter auf "-"
function remotepixel_getCGIParameter () {
if (window.location.search != ""){
//teile den String an allen & Separatoren und schneide zuvor das ? weg
var strParamters = window.location.search.split("?")[1];
var liste = strParamters.split("&");
//gehe durch die key=value Strings und Teile wiederum am =
//jedes key und value wird kurzeitig in einer Liste temp gehalten
for (var i=0;i<=liste.length-1;i++) {
var temp = liste[i].split("=");
//bearbeitung des keys
var strValue = temp[1];
strValue = strValue.replace(/\+/g," ");
strValue = unescape(strValue);
if(strValue == "")
strValue = "-";
this.addParameter( temp[0], strValue);
} //next
}
}// end method remotepixel_getCGIParameter
//==========================================================
//remotepixel_SplitParams
//==========================================================
function remotepixel_SplitParams(params) {
var result=[];
var pairs=params.split("&");
for (var i=0; i < pairs.length; i++) {
var kv=pairs[i].split("=");
if (kv[1] && kv[1] != "")
result[kv[0]]=kv[1];
else
result[kv[0]]="-";
}
return result;
}
//==========================================================
// remotepixel_extractCGIParam
//==========================================================
function remotepixel_extractCGIParam( strParam )
{
if (window.location.search != '')
{
// parameters available
var strParams = window.location.search.split('?')[1];
var aParams = remotepixel_SplitParams( strParams );
if ( aParams[ strParam ] && aParams[ strParam ] != '-')
{
return aParams[ strParam ];
}
}
return "";
}
//==========================================================
//Definition of Prototypes
//==========================================================
//methoden zur Klasse hinzufuegen
cRemotePixel.prototype.convertValue = remotepixel_convertValue;
cRemotePixel.prototype.addParameter = remotepixel_addParameter;
cRemotePixel.prototype.setParameter = remotepixel_setParameter;
cRemotePixel.prototype.addAffiliate = remotepixel_addAffiliate;
cRemotePixel.prototype.addUrl = remotepixel_addUrl;
cRemotePixel.prototype.addReferrer = remotepixel_addReferrer;
cRemotePixel.prototype.getHiddenForm = remotepixel_getHiddenForm;
cRemotePixel.prototype.getXmlHttpInstance = remotepixel_getXmlHttpInstance;
cRemotePixel.prototype.populateForm = remotepixel_populateForm;
cRemotePixel.prototype.postData = remotepixel_postData;
cRemotePixel.prototype.sendData = remotepixel_sendData;
cRemotePixel.prototype.getTechData = remotepixel_getTechData;
cRemotePixel.prototype.getMetaTags = remotepixel_getMetaTags;
cRemotePixel.prototype.getHashParameter = remotepixel_getHashParameter;
cRemotePixel.prototype.getCGIParameter = remotepixel_getCGIParameter;
cRemotePixel.prototype.extractCGIParam = remotepixel_extractCGIParam;
cRemotePixel.prototype.writeDebug = remotepixel_writeDebug;
cRemotePixel.prototype.writeConfig = remotepixel_writeConfig;
//==========================================================
// Convert Wildcard to RegEx
//==========================================================
function WildToReg(str) {
var s = "";
var i;
var c;
for (i = 0; i < str.length; i++) {
c = str.charAt(i);
switch(c) {
case '*':
s = s + ".*";
break;
case '?':
s = s + ".";
break;
case '(': case ')': case '[': case ']': case '$':
case '^': case '.': case '{': case '}': case '|':
case '\\':
s = s + "\\";
s = s + c;
break;
default:
s = s + c;
break;
}//end switch(c)
}//end for (i = 0; i < str.length; i++)
s = "^" + s + "$";
return s;
}//end function WildToReg(str)
//==========================================================
//function Pixel-Instanz anlegen
//==========================================================
function doPixelInstance(oEvent) {
oNMRemotePixel.writeDebug( "Prepare pixel for " + document.URL, "_log_values", true, true );
//Send PartnerName as parameter?
if (oNMConfig.getAutoParams()) {
//Send Url as parameter?
if (oNMConfig.getSendUrl()) {
oNMRemotePixel.addUrl();
}//end if (SendUrl)
//Send Hash Parameter as parameter?
if (oNMConfig.getSendUrlHash()) {
oNMRemotePixel.getHashParameter();
}//end if (SendUrlHash)
//Send referrer as parameter?
if (oNMConfig.getSendReferrer()) {
oNMRemotePixel.addReferrer();
}//end if (SendReferrer)
if(oNMConfig.getSendMetatags()) {
oNMRemotePixel.getMetaTags();
}
if(oNMConfig.getSendTech()) {
oNMRemotePixel.getTechData();
}
if(oNMConfig.getSendCGIParams()) {
oNMRemotePixel.getCGIParameter();
}
} // end autoparams
if(oNMConfig.getAutoSend()) {
oNMRemotePixel.sendData(oNMRemoteSession);
}
} // end function doPixelInstance
//======================================================================================
// Load Time Execution
//======================================================================================
var oNMConfig = new cConfigPixel();
var oNMRemoteSession = new cRemoteSession(oNMConfig);
var oNMRemotePixel = new cRemotePixel(oNMConfig);
//Pixel is fired immedietally
doPixelInstance("");
/*
if( window.addEventListener ) {
//alert ("window.addEventListener");
window.addEventListener('load',doPixelInstance,false);
} else if( document.addEventListener ) {
//alert ("document.addEventListener");
document.addEventListener('load',doPixelInstance,false);
} else if (window.attachEvent) {
//alert ("window.attachEvent");
window.attachEvent('onload', doPixelInstance);
} else if (document.attachEvent) {
//alert ("document.attachEvent");
document.attachEvent('onload', doPixelInstance);
} else {
doPixelInstance("");
}
*/