(function () { function getXpertString() { var ind = document.getElementById('Industry'), reg = document.getElementById('Region'), sol = document.getElementById('CustomerSolution'), msg = ''; if (ind && ind.value) { msg += ind.value; } else { msg += 'Undefined'; } if (reg && reg.value) { msg += '-' + reg.value; } else { msg += '-Undefined'; } if (sol && sol.value) { msg += '-' + sol.value; } else { msg += '-Undefined'; } return msg; }; var Main = { /** * Match and rules lookup table containing custom functions to be bound * to DOM elements based on specific class names */ lookup:{ 'ga-thumb':{ 'on':'click', 'action':function () { var elName = this.textContent || this.innerText; pageTracker._trackEvent('Homepage', 'Thumbnail click', elName); } }, 'ga-xengine-save':{ 'on':'click', 'action':function () { var msg = getXpertString(); pageTracker._trackEvent('Xpertise engine', 'Save', msg); } }, 'ga-xengine-print':{ 'on':'click', 'action':function () { var msg = getXpertString(); pageTracker._trackEvent('Xpertise engine', 'Print', msg); } }, 'ga-xengine-search':{ 'on':'click', 'action':function () { var msg = getXpertString(); pageTracker._trackEvent('Xpertise engine', 'Search', msg); } }, 'ga-xengine-help':{ 'on':'click', 'action':function () { pageTracker._trackEvent('Xpertise engine', 'Help'); } }, 'ga-pdf':{ 'on':'click', 'action':function () { var url = document.location.href, elName = this.title, sections; url = url.split('/').slice(4).join('-'); sections = url.substring(0, url.indexOf('.')); pageTracker._trackEvent(sections, 'Download pdf', elName); } }, 'ga-hero-thumb':{ 'on':'click', 'action':function () { var url = document.location.href, elName = this.title, sections; url = url.split('/').slice(4), section = url[0]; pageTracker._trackEvent(section, 'Thumbnail click', elName); } }, 'ga-ihtml':{ 'on':'click', 'action':function () { var elName = this.textContent || this.innerText; pageTracker._trackEvent('Investor Relations-Annual Reports','Interactive html', elName); } }, 'ga-generic-form-confirmation':{ 'on':'load', 'action':function () { pageTracker._trackPageview(document.location.pathname + '/confirmation'); } }, 'ga-contact-us':{ 'on':'click', 'action':function () { pageTracker._trackEvent('Contact Us','Additional Information Pane'); } }, 'ga-print-results':{ 'on':'click', 'action':function () { var url = document.location.href, url = url.split('/').slice(4), sections; section = url[0]; pageTracker._trackEvent(section, 'Print', document.location); } }, 'ga-video-play':{ 'on':'click', 'action':function () { var url = document.location.href, elName = this.title, url = url.split('/').slice(4), sections; section = url[0]; pageTracker._trackEvent(section,'Video Play', elName); } }, 'ga-video-pause':{ 'on':'click', 'action':function () { var url = document.location.href, elName = this.title, url = url.split('/').slice(4), sections; section = url[0]; pageTracker._trackEvent(section,'Video Pause', elName); } }, 'ga-video-completed':{ 'on':'click', 'action':function () { var url = document.location.href, elName = this.title, url = url.split('/').slice(4), sections; section = url[0]; pageTracker._trackEvent(section,'Video Completed', elName); } } }, /** * Main initialisation function that binds the GA Wrapper to elements * in the DOM * @param {Object} data Contains data to be passed to GA */ init:function () { var elems = document.getElementsByTagName('*'), lookup = this.lookup, classes, c, el, i, j; for (i = 0; elems[i]; i += 1) { el = elems[i]; classes = el.className.split(' '); for (j = 0; classes[j]; j += 1) { c = classes[j]; if (lookup[c]) { if (lookup[c].on === 'load') { lookup[c].fn.call(this); } else { YAHOO.util.Event.on(el, lookup[c].on, lookup[c].action); } } } } } } /* * Set global scope */ if (typeof GoogleAnalyticsWrapper === 'undefined' || !GoogleAnalyticsWrapper) { GoogleAnalyticsWrapper = Main; } })(); GoogleAnalyticsWrapper.init();