﻿/*
* cmXMS.js 
* The following code supports coremetrics tracking for External Marketing Sites
* 
* Created by: Skye Stein
* Last Updated: 05/05/2010
*/

//List of optional variables to be declared for this script
//var clientId = "90298592";
//var sitePrefix = "XMS:";
//var pageName = "Unregistered Page";
//var pageCategoryId = "F010";
//var searchedTerm = null;
//var resultsCount = null;
//var pageViewExploreAttributes = null;
//var isFirstPartyDataCollection = false;
//var hostDomain = "analytics.harpercollins.com";
//var isProductionDataOn = false;
//var debug = false;

if ((typeof (clientId) == "undefined") || (clientId == "")) { var clientId = "90298592"; } //default to US Client ID
if ((typeof (sitePrefix) == "undefined") || (sitePrefix == "")) { var sitePrefix = "XMS:"; } //default to XMS: External Marketing Site Prefix
if ((typeof (pageName) == "undefined") || (pageName == "")) { var pageName = "Unregistered Page"; }
if ((typeof (pageCategoryId) == "undefined") || (pageCategoryId == "")) { var pageCategoryId = "F010"; } //External Marketing Site Category
if ((typeof (searchedTerm) == "undefined") || (searchedTerm == "")) { var searchedTerm = null; }
if ((typeof (resultsCount) == "undefined") || (resultsCount == "")) { var resultsCount = null; }
if ((typeof (pageViewExploreAttributes) == "undefined") || (pageViewExploreAttributes == "")) { var pageViewExploreAttributes = ""; }
if ((typeof (isFirstPartyDataCollection) == "undefined") || (isFirstPartyDataCollection == "")) { var isFirstPartyDataCollection = false; }
if ((typeof (hostDomain) == "undefined") || (hostDomain == "")) { var hostDomain = "analytics.harpercollins.com"; }
if ((typeof (isProductionDataOn) == "undefined") || (isProductionDataOn == "")) { var isProductionDataOn = false; }
if ((typeof (debug) == "undefined") || (debug == "")) { var debug = false; }

if (debug) {
    alert("clientId = " + clientId + "\nsitePrefix = " + sitePrefix + "\npageName = " + pageName + "\npageCategoryId = " + pageCategoryId + "\nsearchedTerm = " + searchedTerm + "\nresultsCount = " + resultsCount + "\npageViewExploreAttributes = " + pageViewExploreAttributes + "\nisFirstPartyDataCollection = " + isFirstPartyDataCollection + "\nhostDomain = " + hostDomain + "\nisProductionDataOn = " + isProductionDataOn);
}

// Set Coremetrics Client ID
cmSetClientID(clientId, isFirstPartyDataCollection, hostDomain);

// True/False to send data to production
if (isProductionDataOn) { cmSetProduction(); }

// Standard Pageview Tag
cmCreatePageviewTag(sitePrefix + pageName, pageCategoryId, searchedTerm, resultsCount, pageViewExploreAttributes);
