/*
This file contains standard metrics helper functions.
DO NOT ADD FUNCTIONS TO SUPPORT A PARTICULAR PROJECT WITHOUT
CHECKING WITH THE APPLICATION TEAM
*/
function OInternalMetrics(){
/* This class does access metrics variables that are outside the class scope (ugh)
* but, the methods are encapsulated and can't be accessed by accident
*/
/* Public Method Pointers */
this.m_clear_tempvalues = m_clear_tempvalues;
this.m_set_FVSection =m_set_FVSection;
this.m_set_s_PageName = m_set_s_PageName;
this.m_set_s_Hierarchy = m_set_s_Hierarchy;
this.m_set_s_Channel = m_set_s_Channel;
this.m_set_s_events = m_set_s_events;
this.m_set_OnClick = m_set_OnClick;
this.m_set_VideoStart = m_set_VideoStart;
this.m_set_VideoComplete = m_set_VideoComplete;
this.m_clear_nameplate = m_clear_nameplate;
this.m_set_nameplate = m_set_nameplate;
this.m_set_v48and49 = m_set_v48and49;
/* Standard function to clear out values that only get recorded once */
function m_clear_tempvalues() {
s_events="";
s_products="";
s_prop5="";
s_prop6="";
s_prop7="";
s_prop48="";
s_prop49="";
s_eVar48="";
s_eVar49="";
}
/* IVISection helper functions */
function m_set_FVSection(sS) {
if (sS.length > 0) FVSection=m_cleanData(sS);
}
/*
Set Pagename: sets the value for the pagename variable
Default behaviour is append the value passed in to the BasePageName
bO: Override. Sets sS to the full value passed in
*/
function m_set_s_PageName (sPN, bO) {
var sTemp
//only change the pagename if len > 0
if (sPN.length > 0) {
if (bO == 1)
sTemp= (s_siteID + ":" + sPN)
else
sTemp = (s_siteID + BasePageName + ":" + sPN)
}
s_pageName=m_cleanData(sTemp);
}
/* Set sHierarchy: sets the value of the js variable */
function m_set_s_Hierarchy(sH){
s_hier1=sH;
}
/*
Set sChannel: sets the value of the js variable
Note: Is this a ":" delimited list as well? so far only single values used.
*/
function m_set_s_Channel (sC) {
s_channel=m_cleanData(sC);
}
/*
set events: sets the success events variables
It is up to the calling function to clear out any old events
This function appends only.
*/
function m_set_s_events(sE, seVar28) {
if (s_events.length > 0){
s_events = (s_events + ";")
}
s_events = m_cleanData(s_events + sE);
if (typeof(seVar28)!="undefined"){
s_eVar28 = m_cleanData(seVar28);
}
}
/*
Standard function to set the value for an on-click event.
Used for "doing things" on a previously set pagename
*/
function m_set_OnClick(sA) {
s_prop5=m_cleanData(sA)
}
/*
Standard function to set the value for a Video Start OnCLick event.
Used for "doing things" on a previously set pagename
*/
function m_set_VideoStart(sA) {
s_prop6=m_cleanData(sA)
}
/*
Standard function to set the value for a Video Complete OnCLick event.
Used for "doing things" on a previously set pagename
*/
function m_set_VideoComplete(sA) {
s_prop7=m_cleanData(sA)
}
function m_clear_nameplate() {
s_nameplate="";
s_modelyear="";
}
/*
Set nameplate: This function should only be used when nameplate data needs
to be set dynamically. Otherwise, value in parser is preferred.
*/
function m_set_nameplate (sNameplate, sModelYear) {
s_nameplate=m_cleanData(sNameplate);
s_modelyear=m_cleanData(sModelYear);
}
/*
New function to set the value v48 and v49
Used for "adding variables" with the set pagename
*/
function m_set_v48and49(s48, s49) {
s_prop48=m_cleanData(s48);
s_prop49=m_cleanData(s49);
s_eVar48=m_cleanData(s48);
s_eVar49=m_cleanData(s49);
}
/* TRUELY PRIVATE METHODS */
function m_cleanData(sString) {
//cleanse the data for Omniture
sString=(((sString.toLowerCase()).replace(/'/g,"")));
sString=escape(sString);
sString=unescape(sString);
return sString
}
}
/* *********** END CLASS *********** */
/*Misc functions that were added for some project */
function promoMetricsForExternalSite(sLink, sPageName){
mVirtualPage(sPageName, '', '');
popInternal(sLink);
}
function popInternal(sURL) {
// function to open without popup message
n = window.open(sURL, 'n', 'width=750,height=555,location=yes,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
n.focus();
}
/* Standard omniture functions for sending metrics. Moved from in-line */
function sendAnalyticsEvent(str){
ns=s_account; if(str!=null)ns+=","+str;void(s_gs(ns));
}
function sendLinkEvent(str,lnkname){
ns=s_account; if(str!=null)ns+=","+str;s_linkType=str;s_linkName=lnkname;void(s_gs(ns));
}
/* NEW EVENT CALL */
function sendLinkEventNew(str,lnkname){
ns=s_account; if(str!="" || str!=null)ns+=","+str; s_linkType="o"; s_lnk=true;
s_linkName=lnkname; void(s_gs(ns));
}
/* Standard function for section load in IVI */
function mFVSectionLoad(sSection, sChannel, sHierarchy, sSubsectionStr) {
var oMetrics = new OInternalMetrics()
oMetrics.m_clear_tempvalues()
//re-set section if necessary
if (sSection.length > 0) oMetrics.m_set_FVSection (sSection);
//append susection if required
if (sSubsectionStr!=undefined && sSubsectionStr.length > 0)
oMetrics.m_set_s_PageName (FVSection + ":" + sSubsectionStr, 0);
else
oMetrics.m_set_s_PageName (FVSection, 0);
//Don't set channel anymore. Should change the interface at some point.
//if (sChannel.length > 0) m_set_s_Channel (sChannel);
//append new value to base value
if (sHierarchy.length > 0) oMetrics.m_set_s_Hierarchy(BaseHierarchy + ":" + sHierarchy);
sendAnalyticsEvent('');
}
function mFVContentActivity(sActivity) {
//wrapper function for the core flash app, in case it needs to do something different than modules
mContentActivity (sActivity);
}
/*
Standard function to append further information to the BasePageName value
and trigger a metricsevent. Used for flash/dhtml events
nType=1 : Send link event, not Analytics
bOverride=1 : do not append, just overwrite the pagename
*/
function mVirtualPage (sPageName, sChannel, sHierarchy) {
var oMetrics = new OInternalMetrics()
oMetrics.m_set_s_PageName (sPageName, 1);
oMetrics.m_set_s_Channel (sChannel);
oMetrics.m_set_s_Hierarchy(sHierarchy);
oMetrics.m_clear_tempvalues();
sendAnalyticsEvent('');
}
//Used for most flash/dhtml page views (non-specialized)
function mContentView (sPageName, bOverride) {
var oMetrics = new OInternalMetrics()
// sets the page name and triggers send metrics events
oMetrics.m_set_s_PageName (sPageName, bOverride);
oMetrics.m_clear_tempvalues();
sendAnalyticsEvent('');
}
//Used for most flash/dhtml page views, set Page Name and v48 and v49
function mContentViewAnd48_49 (sPageName, s48, s49) {
var oMetrics = new OInternalMetrics()
// sets the page name and triggers send metrics events
oMetrics.m_set_s_PageName (sPageName);
oMetrics.m_clear_tempvalues();
oMetrics.m_set_v48and49(s48, s49)
sendAnalyticsEvent('');
}
//Used for most flash/dhtml page views, set c5 and v48 and v49
function mContentActivityAnd48_49 (sActivity, s48, s49) {
var oMetrics = new OInternalMetrics()
oMetrics.m_set_OnClick(sActivity);
oMetrics.m_set_v48and49(s48, s49);
sendAnalyticsEvent('');
}
//Another call for mContentView (vendor screwup)
function sendMetrics (sPageName, bOverride) {
var oMetrics = new OInternalMetrics()
// sets the page name and triggers send metrics events
oMetrics.m_set_s_PageName (sPageName, bOverride);
oMetrics.m_clear_tempvalues();
sendAnalyticsEvent('');
}
/*
Note: for mContentActivity it can now accept 3 parameters
sActivity = #descriptor#
sLinkType = o (default)
e (exit link)
d (download)
sEvents = "eventX, eventX" comma delimited list
*/
function mContentActivity (sActivity, sLinkType, sEvents) {
//just triggers an "onClick" for something on an existing page.
var oMetrics = new OInternalMetrics()
oMetrics.m_clear_tempvalues();
if(!sLinkType){
s_linkType='o';
} else {
s_linkType=sLinkType;
}
s_linkName=sActivity;
// vars and events need to be declared before to enable sending
s_linkTrackVars='s_channel,s_hier1,s_events,s_eVar15,s_eVar14,s_eVar12,s_eVar16,s_prop14,s_prop15,s_prop12,s_prop16,s_prop5';
if(sEvents){
s_linkTrackEvents=sEvents;
s_events=sEvents;
}
s_prop12='';s_eVar12='';
s_prop14='';s_eVar14='';
s_prop15='';s_eVar15='';
s_prop16='';s_eVar16='';
oMetrics.m_set_OnClick(sActivity);
s_lnk=s_co(this);s_gs('');
}
/*
NOTE: only use for a referral exit link
This is specifically called for an exit link going to a fv referral only: sets eVar6 and appends referral to the c5
*/
function mContentActivityRef (sActivity, sEvents) {
//triggers an "onClick" for something on an existing page that goes within the fv site.
var oMetrics = new OInternalMetrics()
oMetrics.m_clear_tempvalues();
s_linkType='e';
s_linkName=sActivity;
// vars and events need to be declared before to enable sending
s_linkTrackVars='s_channel,s_hier1,s_events,s_eVar6,s_eVar15,s_eVar14,s_eVar12,s_eVar16,s_prop5,s_prop14,s_prop15,s_prop12,s_prop16,s_prop5';
if(sEvents){
s_linkTrackEvents=sEvents;
s_events=sEvents;
}
s_eVar6=sActivity;
s_prop12='';s_eVar12='';
s_prop14='';s_eVar14='';
s_prop15='';s_eVar15='';
s_prop16='';s_eVar16='';
oMetrics.m_set_OnClick("referral:" + sActivity);
s_lnk=s_co(this);s_gs('');
}
function mVideoActivity (sVideoName,bComplete) {
var oMetrics = new OInternalMetrics()
oMetrics.m_clear_tempvalues();
if (bComplete==0){
oMetrics.m_set_VideoStart(sVideoName);
} else {
oMetrics.m_set_VideoComplete(sVideoName);
}
sendLinkEvent('');
}
function mDownloadBrochure(sPageName, bOverride) {
var oMetrics = new OInternalMetrics()
oMetrics.m_set_s_PageName (sPageName, bOverride);
oMetrics.m_clear_tempvalues();
mEventAndFloodLightMetrics()
// oMetrics.m_set_s_events("event15");
sendAnalyticsEvent('');
oMetrics.m_clear_tempvalues();
}
/*The following functions are being depricated to support ongoing metrics tweaking. Do not re-use */
function MEFlash(var1){
//deprecated. redirect to mContentView
mContentView(var1);
}
function ME( sec, pe, ped, trm, clr, fvevent) {
// Measure Me Event .... will ve invoked when the page will be loaded/from flash to send data to Omniture
//deprecated.
}
var js_sCat = "rhp"
var js_sNamePlate = ""
var sMetricEvent_Delayed = "event"
var sMetricEvent_DelayedEVar28 = ""
var sDelayEvent = ""
var sDelayFloodLight = ""
function OFloodLight(){
this.createFloodLight = createFloodLight;
this.fireFloodlight = fireFloodlight;
//this was used in order to dynamically fire during the viewing of a page(video start/stop)
function fireFloodlight(sCat, sNamePlate){
var strsrc = 'https://fls.doubleclick.net/activityi;src=690327;type=fvflup;cat=' + sCat + ';u1=' + sNamePlate + ';u6=1;ord=?'
var objIFrame = document.getElementById("IfrmFlood");
if(objIFrame){
objIFrame.src = strsrc;
}
}
function createFloodLight(sCat, sNamePlate, delayedFloodlight){
var axel = Math.random()+"";
var a = axel * 10000000000000;
//added delayedFloodlight in order to capture a floodlight call onClick
if (delayedFloodlight || window.navigator.userAgent.search(/Firefox/) > 0){
// Code exception for firefox
var node = document.createElement("div")
node.innerHTML = ''
document.body.appendChild(node)
}else {
document.write('');
}
}
}
oFloodLight = new OFloodLight()
function mEventMetrics( ){
var oMetrics = new OInternalMetrics()
oMetrics.m_set_s_events(sMetricEvent_Delayed, sMetricEvent_DelayedEVar28)
}
function mFloodLightMetrics(sCat, sNamePlate){
if (sDelayFloodLight != "true"){
oFloodLight.createFloodLight(sCat, sNamePlate)
}
}
/*
This is used when initiating a floodlight call on an event vs in the url
note: delay_floodlight has to be referenced in the urls.xml
*/
function mFloodLightMetricsDelay(sCat, sNamePlate){
var oMetrics = new OInternalMetrics();
oMetrics.m_set_s_events(sMetricEvent_Delayed, sMetricEvent_DelayedEVar28);
oFloodLight.createFloodLight(sCat, sNamePlate, true);
}
// Only use for delayed Event and delayed Floodlight
function mEventAndFloodLightMetrics(){
var oMetrics = new OInternalMetrics()
oMetrics.m_set_s_events(sMetricEvent_Delayed, sMetricEvent_DelayedEVar28)
//added argument for delay (onclick)
oFloodLight.createFloodLight(js_sCat, js_sNamePlate, true)
}