(function () { // v1.1 if (typeof _gaq == undefined || typeof _gaq == 'undefined') { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = false; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; document.getElementsByTagName('head')[0].appendChild(ga); } })(); var _gaq = _gaq || []; var _gaEmbedVideoReport = (new function () { var dhn = document.location.hostname; // Set the production WP id (or the one that is mimicking it until the code goes live) var gaUA_ID = 'UA-30171705-1'; // new live when main tracking goes live +- Thurs 4/5 or Monday 4/9 // QA //var gaUA_ID = 'UA-26700348-1'; // Current live "MSNBC cable" GA account. this.sendPageView = 0; this.runGA = function runGA(videoSource, categoryName, eventName, eventLabel, eventValue, eventLogicalSite) { eventValue = parseInt(eventValue, 10); eventValue = isNaN(eventValue) ? 0 : eventValue; var cv4 = dhn.match(/(msnbc\.msn|newsvine)\.com$/i); // BK vid1.1 moved into runGA from _gaEmbedVideoReport var isNewVisit = false; if (cv4) { cv4 = cv4[1]; gaUA_ID = (/(sys\d+|gamma|ppe|assets[abcd])\./.test(dhn)) ? 'UA-25844400-1' : gaUA_ID; _gaq.push(['msnbcvideo._setAccount', gaUA_ID]); if ('newsvine' == cv4) { var iHash = '154396583'; _gaq.push(['msnbcvideo._setDomainName', '.newsvine.com']); } else { cv4 = dhn.match(/^[^.]+/)[0]; cv4 = ('www' == cv4 ? 'www.msnbc' : ('today' == cv4 ? 'todayshow' : cv4)); iHash = '238145375'; _gaq.push(['msnbcvideo._setDomainName', '.msnbc.msn.com']); } var regExpNewVisit = new RegExp('__utmb=' + iHash + '\.'); isNewVisit = !regExpNewVisit.test(document.cookie); } else { _gaq.push(['msnbcvideo._setAccount', gaUA_ID]); if (0 == this.sendPageView) { this.sendPageView = 1; } cv4 = dhn; // BK's Note: On some external sites using GA it's difficult to determine the start of a visit without our own cookie // Preferable to set CV#3 to "Earned" and CV#8 on each call // BK vid1.1 Changed isNewVisit to true and removed regExpNewVisit = /__utmb=\d+/; isNewVisit = true; } _gaq.push(['msnbcvideo._setCustomVar', 1, 'Video Source', videoSource, 3]); // use different variable for Video source _gaq.push(['msnbcvideo._setCustomVar', 2, 'Content', 'Original', 3]); if (!eventLogicalSite) { eventLogicalSite = "other"; } if (isNewVisit) { _gaq.push(['msnbcvideo._setCustomVar', 3, 'Visit Type', 'Earned', 2]); _gaq.push(['msnbcvideo._setCustomVar', 8, 'Earned By', eventLogicalSite + '|Video|' + cv4, 1]);// BK vid1.1 Added eventLogicalSite _gaq.push(['msnbcvideo._setCustomVar', 30, 'Visit Type to Content', 'Earned to Original', 1]); // BK vid1.1 Added #30 } _gaq.push(['msnbcvideo._setCustomVar', 4, 'Actual Site', 'Video|' + cv4, 3]); // BK vid1.1 Added Actual _gaq.push(['msnbcvideo._setCustomVar', 10, 'Ver', 'vid1.1', 3]); // version number for diagnostics, distinguishing from Analytics.js data and from "rogue" analytics _gaq.push(['msnbcvideo._setCustomVar', 11, 'Logical Site', eventLogicalSite, 3]); if (1 == this.sendPageView) { var pageName = document.location.pathname + document.location.hash; pageName = pageName.split('#.')[0]; _gaq.push(['msnbcvideo._trackPageview', pageName]); this.sendPageView++; } _gaq.push(['msnbcvideo._trackEvent', categoryName, eventName, eventLabel, eventValue]); } } ());