1// Tealium utag load and click event hookup 2var utag_data = {}; 3 4function getEnvironment() { 5 var env_map = ({"dev": "dev", "sit": "qa", "qa": "qa", "uat": "qa", "perf": "qa", "prd": "prod"}); 6 if (document.location.href.indexOf('3000') >= 0 || document.location.hostname.includes('local')) { 7 return "dev"; 8 } 9 return env_map[(document.location.hostname.match(/-(dev|sit|qa|uat|perf)/) || ["","prd"])[1]]; 10} 11 12var tl_environment = getEnvironment(); 13 14 15// LFox 12/13/2019 - leaving readAudienceFromCookie as an example for now as to how to get data from P14N. 16// P14N will be deprecated and removed in 2020, but if needed temporarily, this example will come in handy. 17// 18//function readAudienceFromCookie(){ 19// function isP14N(s) { return s.slice(0,4) == 'P14N'; } 20// try { 21// var raw = document.cookie.split(/;\s*/).filter(isP14N)[0] 22// var json = decodeURIComponent(raw.substr(5)); 23// var p14n = JSON.parse(json); 24// return p14n.audience; 25// } catch (e) { 26// return 'unknown_audience'; // so that it'll be easy to grep for if this ever happens 27// } 28//} 29 30function readNonUmpAudience(pathname) { 31 if (pathname.match(/\/member\b/)) { 32 return ('individual'); 33 } else if (pathname.match(/\/medicare\b/)) { 34 return ('medicare'); 35 } else if (pathname.match(/\/provider\b/)) { 36 return ('provider'); 37 } else if (pathname.match(/\/producer\b/)) { 38 return ('producer'); 39 } else if (pathname.match(/\/employer\b/)) { 40 return ('employer'); 41 } 42 return 'common'; 43} 44 45// The assignment of tl_audience in the event listener below was previously 46// tl_audience = tealium_data.audience || readNonUmpAudience(); 47// It now invokes this function, which checks to see if the domain matches 'ump.regence.com' or 48// any of the other environment domains like 'ump-dev.regence.com', then checks the pathname 49// to see if it contains '/sebb' or '/pebb' and returns the appropriate value or the default 50// UMP value. Or it checks the domain to see if it contains '/ump', and returns the UMP value. 51// Otherwise, readNonUmpAudience(pathname) is called. 52function readAudienceFromPageInfo(domain, pathname, audience) { 53 if (domain.match(/ump.*\.regence\.com/)) { 54 if (pathname.match(/\/sebb\b/)) { 55 return ('sebb_individual'); 56 } 57 else if (pathname.match(/\/pebb\b/)) { 58 return ('pebb_individual'); 59 } 60 else { 61 return ('ump_individual'); 62 } 63 } 64 else if (pathname.match(/\/ump\b/)) { 65 return ('ump_individual'); 66 } 67 else { 68 return readNonUmpAudience(pathname); 69 } 70} 71 72// function reloadTealiumYoutube() { 73// if (jQuery('iframe[src*="youtube.com"]').length > 0) { 74// var i = 0, 75// id; 76// window.iframe_id = []; 77// jQuery('iframe[src*="youtube.com"]').each(function() { 78// if (jQuery(this).attr("id")) { 79// id = jQuery(this).attr("id"); 80// window.iframe_id.push(id); 81// } else { 82// id = "tealium_youtube" + i; 83// jQuery(this).attr("id", id); 84// window.iframe_id.push(id); 85// i++; 86// } 87// }); 88// } 89 // Configure Milestones 90 // 91// function setMileStones(i) { 92// // Set the intervals here as you want them reported, in % viewed, each number separated by a comma 93// // If you do not want mileStones set mileStones[i] = [] ; 94// mileStones[i] = [10, 25, 50, 75, 90]; 95// } 96// var mileStones = []; 97// if (window.iframe_id) { 98// for (i = 0; i < window.iframe_id.length; i++) { 99// setMileStones(i); 100// } 101// } 102// // Load the YouTube iframe library 103// // 104// var scriptref = document.getElementsByTagName("script")[0]; 105// if (scriptref.src !== "https://www.youtube.com/iframe_api") { 106// var ytapi = document.createElement("script"); 107// ytapi.src = "https://www.youtube.com/iframe_api"; 108// scriptref.parentNode.insertBefore(ytapi, scriptref); 109// } 110// window.players = []; 111// window.onYouTubeIframeAPIReady = function() { 112// // Confirm existing ID or set ID in the iframe for each video on the page 113// jQuery('iframe[src*="youtube.com"]').each(function() { 114// var id = jQuery(this).attr("id"); 115// window.players[id] = new YT.Player(id, { 116// events: { 117// onReady: onPlayerReady, 118// onStateChange: onPlayerStateChange 119// } 120// }); 121// }); 122// }; 123// window.start = []; 124// window.onPlayerReady = function(event) { 125// //Log that the video is ready/open 126// var idx; 127// for (i = 0; i < window.iframe_id.length; i++) { 128// if (window.iframe_id[i] === event.target.getIframe().id) { 129// idx = i; 130// } 131// window.start.push(true); 132// } 133// if (event.target.getPlayerState() === YT.PlayerState.CUED) { 134// var player = event.target; 135// var player_data = player.getVideoData();
136// utag.link({ 137// tealium_event: "video_load", 138// video_id: player_data.video_id, 139// video_length: Math.round(player.getDuration()).toString(), 140// video_name: player_data.title, 141// video_platform: "YouTube" 142// }); 143// } 144// }; 145 146// var playerCheckInterval, event; 147// window.onPlayerStateChange = function(event) { 148// player = event.target; 149// var playhead, idx; 150// for (i = 0; i < window.iframe_id.length; i++) { 151// if (window.iframe_id[i] === event.target.getIframe().id) { 152// idx = i; 153// } 154// } 155// tealium_event = ""; 156// if (event.data == YT.PlayerState.PLAYING) { 157// if (start[idx]) { 158// if (mileStones[idx].length > 0) { 159// playerCheckInterval = setInterval(mileStoneCheck, 50); 160// } 161// tealium_event = "video_start"; 162// playhead = 0; 163// } else { 164// //This will catch when the video playback is changed from not playing to playing 165// tealium_event = "video_play"; 166// playhead = player.getCurrentTime().toString(); 167// } 168// start[idx] = false; 169// } else if (event.data == YT.PlayerState.PAUSED) { 170// tealium_event = "video_pause"; 171// playhead = player.getCurrentTime().toString(); 172// } else if (event.data == YT.PlayerState.ENDED) { 173// if (mileStones[idx].length > 0) { 174// clearInterval(playerCheckInterval); 175// // reset in case visitor replays the video 176// playerCheckInterval = 0; 177// setMileStones(idx); 178// } 179// tealium_event = "video_complete"; // utag 180// playhead = Math.round(player.getDuration()).toString(); 181// } 182// if (tealium_event) { 183// window.utag.DB( 184// "Video event: " + tealium_event + ", video ID: " + window.iframe_id[idx] 185// ); 186// var player_data = player.getVideoData(); 187// window.utag.link({ 188// tealium_event: tealium_event, 189// video_playhead: parseInt(playhead).toString(), 190// video_id: player_data.video_id, 191// video_length: Math.round(player.getDuration()).toString(), 192// video_name: player_data.title, 193// video_platform: "YouTube" 194// }); 195// } 196// function mileStoneCheck() { 197// var idx; 198// for (i = 0; i < window.iframe_id.length; i++) { 199// if (window.iframe_id[i] === player.getIframe().id) { 200// idx = i; 201// } 202// } 203// var duration = Math.round(player.getDuration()); 204// var playhead = parseInt(player.getCurrentTime()); 205// var percComplete = (playhead / duration) * 100; 206// var ms_len = mileStones[idx].length; 207// if (ms_len > 0) { 208// var next_ms = mileStones[idx][0]; 209// if (next_ms <= percComplete) { 210// mileStones[idx].shift(); 211// utag.DB( 212// "Video event: video_milestone, video ID: " + 213// window.iframe_id[idx] + 214// ", Milestone=" + 215// percComplete.toFixed() 216// ); 217// var player_data = player.getVideoData(); 218// window.utag.link({ 219// tealium_event: "video_milestone", 220// video_playhead: parseInt(playhead).toString(), 221// video_id: player_data.video_id, 222// video_length: duration.toString(), 223// video_milestone: next_ms.toString(), 224// video_name: player_data.title, 225// video_platform: "YouTube" 226// }); 227// } 228// } 229// } 230// } 231// if (window.YT) { 232// window.onYouTubeIframeAPIReady(); 233// } 234// } 235 236// From portal's tealium.js filter 237function main() { 238 var tl_brand = 'regence'; 239 var tl_capital_brand = 'Regence'; 240 241 if (document.location.hostname.indexOf('asuris') > 0) { 242 tl_brand = 'asuris'; 243 tl_capital_brand = 'Asuris'; 244 } 245 if (document.location.hostname.indexOf('bridgespan') > 0) { 246 tl_brand = 'bridgespan'; 247 tl_capital_brand = 'Bridgespan'; 248 } 249 250 var tl_splitUrl = document.location.pathname.split('/'); 251 var tl_page_url = "home"; 252 if (tl_splitUrl.length > 2) { 253 tl_page_url = tl_splitUrl[tl_splitUrl.length-1]; 254 if ((typeof tl_page_url === 'undefined') 255 || (tl_page_url == '')) 256 { tl_page_url = tl_splitUrl[tl_splitUrl.length-2]; } 257 if ((typeof tl_page_url === 'undefined') 258 || (tl_page_url == '')) 259 { tl_page_url = "home"; } 260 } 261 var tl_locale = tealium_data.locale.split('-'); 262 var tl_language_code = 'zz'; 263 if (tl_locale.length > 0 && tl_locale[0]) { 264 tl_language_code = tl_locale[0];
265 } 266 var tl_country_code = 'ZZ'; 267 if (tl_locale.length > 1 && tl_locale[1]) { 268 tl_country_code = tl_locale[1].toUpperCase(); 269 } 270 var tl_signed_in = tealium_data.signedIn == 'true' ? '1' : '0'; 271 var tl_user_type = tealium_data.signedIn == 'true' ? 'member' : 'guest'; 272 var tl_person_id = tealium_data.personId ? tealium_data.personId : ''; 273 var tl_line_of_business_id = tealium_data.lineOfBusinessId ? tealium_data.lineOfBusinessId : ''; 274 var tl_user_firstname = tealium_data.firstName ? tealium_data.firstName : ''; 275 var tl_user_email = ''; 276 var tl_mobile = 'web'; // Liferay.Browser.isMobile() ? 'mobile' : 'web'; 277 var tl_section_name = 'Home'; 278 var tl_page_type = tealium_data.pageType || "Page load event"; 279 var tl_audience = readAudienceFromPageInfo(document.location.hostname, document.location.pathname, tealium_data.audience); 280 var tl_state = tealium_data.state; 281 var tl_region = tealium_data.region; 282 var tl_group_id = tealium_data.groupId; 283 var tl_group_name = tealium_data.groupName; 284 285 var tl_login = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*tealium-login\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1"); 286 287 // The Analytics team wants tl_public_private to indicate if the user is signed in or not, not if the page is 288 // public vs. private. That is a change from the previous requirement on Liferay. If the user is signed in, 289 // the value should be private even when the user has navigated to a public page. 290 var tl_public_private = tealium_data.signedIn == 'true' ? 'private' : 'public'; 291 var tl_page_name = tl_brand + '>>' + tl_public_private + '>' + tl_audience + '>' + tl_page_url; 292 293 //Get section and page from Breadcrumbs 294 // var breadcrumbs = document.getElementsByClassName("breadcrumbs"); 295 // if(breadcrumbs.length) { 296 // if(breadcrumbs.length > 1 && jQuery('.breadcrumbEnd span a').text() === jQuery('.breadcrumbs li:nth-child(2)').text()) { 297 // tl_page_type = 'landing'; 298 // } else { 299 // tl_page_type = 'content'; 300 // } 301 // tl_page_name = jQuery('.breadcrumbEnd span a').text(); 302 // if(breadcrumbs.length > 1) { 303 // tl_section_name = jQuery('.breadcrumbs li:nth-child(2)').text(); 304 // } else { 305 // tl_section_name = tl_page_name; 306 // } 307 // } 308 309 utag_data = { 310 "customer_email" : tl_user_email, //Suggested 311 "customer_first_name" : tl_user_firstname, //Suggested 312 "customer_id" : "", //Suggested, included for backwards compatibilty even though we don't have access to the value 313 "customer_is_logged_in" : tl_signed_in, //Suggested 314 "customer_type" : tl_user_type, //Suggested 315 "page_friendly_url" : tl_page_url, //Suggested 316 "page_name" : tl_page_name, //Required 317 "portal_id" : tl_person_id, //Required 318 "line_of_business_id" : tl_line_of_business_id, //Required 319 "group_id" : tl_group_id, //Required 320 "group_name" : tl_group_name, //Required 321 "site_audience" : tl_audience, //Required 322 "site_brand" : tl_capital_brand, //Suggested 323 "site_region" : tl_region, //Suggested 324 "site_state" : tl_state, //Suggested 325 "site_section" : tl_section_name, //Required 326 "site_country_code" : tl_country_code, //Suggested 327 "site_display_format" : tl_mobile, //Required 328 "site_language_code" : tl_language_code, //Suggested 329 "tealium_event" : tl_page_type //Required 330 }; 331 332 (function(d, s, id) { 333 var js, fjs = d.getElementsByTagName(s)[0]; 334 if (d.getElementById(id)) { return; } 335 js = d.createElement(s); 336 js = d.createElement('script'); 337 js.id = id; 338 js.type = "text/javascript"; 339 js.async = true; 340 js.onload = function() { 341 // Fire the signed_in event if necessary 342 if (tl_login != undefined && tl_login != null && tl_login != "") { 343 utag.link({"sso_sign_in" : tl_login == "sso", 344 "tealium_event" : "signed_in"}); 345 } 346// reloadTealiumYoutube(); 347 }; 348 js.src='//tags.tiqcdn.com/utag/cambia/main/' + tl_environment + '/utag.js'; 349 fjs.parentNode.insertBefore(js, fjs); 350 }(document, 'script', 'adif-utag-script')); 351 352 if (window.document) { 353// document.addEventListener('video-modal-launch', function () { reloadTealiumYoutube(); }) 354 } 355}; 356 357// tealiumSetup.js is loaded via an async script tag, so 358// check if DOMContentLoaded has already occurred 359var OnDOMReady = function (callback) { 360 document.readyState === "interactive" || document.readyState === "complete" 361 ? callback() 362 : document.addEventListener("DOMContentLoaded", callback); 363}; 364 365OnDOMReady(main);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.