src/js/tracker.js
/**
		 * Log the page view / visit
		 *
		 * @param string customTitle The user-defined page title to attach to this page view
		 * @param object context Custom context relating to the event
		 */
Log the page view / visit
@param string customTitle The user-defined page title to attach to this page view
@param object context Custom context relating to the event
Log the page view / visit @param string customTitle The user - defined page title to attach to this page view @param object context Custom context relating to the event
function logPageView(customTitle, context) {
			var pageTitle = helpers.fixupTitle(customTitle || configTitle);
			var sb = payload.payloadBuilder(configEncodeBase64);
			sb.add('e', 'pv'); 
			sb.add('page', pageTitle);
			sb.addJson('cx', 'co', completeContext(context));
			var request = getRequest(sb);
			sendRequest(request, configTrackerPause);
			var now = new Date();
			if (configMinimumVisitTime && configHeartBeatTimer && !activityTrackingInstalled) {
				activityTrackingInstalled = true;
				resetMaxScrolls();
				helpers.addEventListener(documentAlias, 'click', activityHandler);
				helpers.addEventListener(documentAlias, 'mouseup', activityHandler);
				helpers.addEventListener(documentAlias, 'mousedown', activityHandler);
				helpers.addEventListener(documentAlias, 'mousemove', activityHandler);
				helpers.addEventListener(documentAlias, 'mousewheel', activityHandler);
				helpers.addEventListener(windowAlias, 'DOMMouseScroll', activityHandler);
				helpers.addEventListener(windowAlias, 'scroll', scrollHandler); 
				helpers.addEventListener(documentAlias, 'keypress', activityHandler);
				helpers.addEventListener(documentAlias, 'keydown', activityHandler);
				helpers.addEventListener(documentAlias, 'keyup', activityHandler);
				helpers.addEventListener(windowAlias, 'resize', activityHandler);
				helpers.addEventListener(windowAlias, 'focus', activityHandler);
				helpers.addEventListener(windowAlias, 'blur', activityHandler);
				lastActivityTime = now.getTime();
				setInterval(function heartBeat() {
					var now = new Date();
					if ((lastActivityTime + configHeartBeatTimer) > now.getTime()) {
						if (configMinimumVisitTime < now.getTime()) {
							logPagePing(pageTitle, context); 
						}
					}
				}, configHeartBeatTimer);
			}
		}
function logPageView ( customTitle , context ) { var pageTitle = helpers . fixupTitle ( customTitle || configTitle ) ; var sb = payload . payloadBuilder ( configEncodeBase64 ) ; sb . add ( 'e' , 'pv' ) ; sb . add ( 'page' , pageTitle ) ; sb . addJson ( 'cx' , 'co' , completeContext ( context ) ) ; var request = getRequest ( sb ) ; sendRequest ( request , configTrackerPause ) ; var now = new Date ( ) ; if ( configMinimumVisitTime && configHeartBeatTimer && ! activityTrackingInstalled ) { activityTrackingInstalled = true ; resetMaxScrolls ( ) ; helpers . addEventListener ( documentAlias , 'click' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'mouseup' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'mousedown' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'mousemove' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'mousewheel' , activityHandler ) ; helpers . addEventListener ( windowAlias , 'DOMMouseScroll' , activityHandler ) ; helpers . addEventListener ( windowAlias , 'scroll' , scrollHandler ) ; helpers . addEventListener ( documentAlias , 'keypress' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'keydown' , activityHandler ) ; helpers . addEventListener ( documentAlias , 'keyup' , activityHandler ) ; helpers . addEventListener ( windowAlias , 'resize' , activityHandler ) ; helpers . addEventListener ( windowAlias , 'focus' , activityHandler ) ; helpers . addEventListener ( windowAlias , 'blur' , activityHandler ) ; lastActivityTime = now . getTime ( ) ; setInterval ( function heartBeat ( ) { var now = new Date ( ) ; if ( ( lastActivityTime + configHeartBeatTimer ) > now . getTime ( ) ) { if ( configMinimumVisitTime < now . getTime ( ) ) { logPagePing ( pageTitle , context ) ; } } } , configHeartBeatTimer ) ; } }
Log the page view / visit
 @param string customTitle The user-defined page title to attach to this page view
 @param object context Custom context relating to the event
Log the page view / visit @param string customTitle The user - defined page title to attach to this page view @param object context Custom context relating to the event
// Fixup page title. We'll pass this to logPagePing too. // Log page view // 'pv' for Page View // Send ping (to log that user has stayed on page) // Capture our initial scroll points // Add event handlers; cross-browser compatibility here varies significantly // @see http://quirksmode.org/dom/events // Will updateMaxScrolls() for us // Periodic check for activity. // There was activity during the heart beat period; // on average, this is going to overstate the visitDuration by configHeartBeatTimer/2 // Send ping if minimum visit time has elapsed // Grab the min/max globals