document.title = 'Allianz Careers'; (function () { function init() { // Add event listner when DOM is ready Call onDomReady function window.addEventListener('load', onDomReady); // Declare components var componentList = {}; const components = [] const excludedNames = [ 'Clear text', 'hamburger menu', 'Language selected', '-', 'previous slide', 'next slide', 'go to slide', 'Learn more', 'Back', 'vorherige', 'See more', 'Unnamed', 'Schließen', 'Apply', 'Clear', 'Filter', 'Cancel', 'Senden', 'Close', 'send', 'video', 'Search results', 'More Options', 'button', 'previous', 'Search'] function shouldExcludeComponent(el, name) { if (el.closest('#onetrust-consent-sdk')) return true if (el.classList.contains('phs-location-link')) return true if (excludedNames.some(ex => name.toLowerCase().includes(ex.toLowerCase()))) return true return false } function detectComponents() { document.querySelectorAll('a, button').forEach((el) => { const ariaLabel = el.getAttribute('aria-label') || '' const textContent = el.textContent.trim().replace(/\s+/g, ' ') let name = ariaLabel || textContent || 'Unnamed' name = name.replace(/^\d+\s+/, '').trim() if (shouldExcludeComponent(el, name)) return let type = 'Unknown' if (el.classList.contains('phw-btn')) { type = 'Button' } else if (el.classList.contains('phw-link')) { type = 'Link' } else if (el.classList.contains('phw-header-logo')) { type = 'Image' } else { type = el.tagName.toLowerCase() === 'button' ? 'Button' : 'Link' } const inHeader = el.closest('header') const inFooter = el.closest('footer') let prefix = '' if (inHeader) prefix = 'header_' else if (inFooter) prefix = 'footer_' let componentId = prefix + name componentId = componentId.replace(/^\d+\s+/, '').trim() if (componentList[componentId]) return componentList[componentId] = { type: type, name: name, linkId: el.getAttribute('href') || 'None', } components.push({ componentInfo: { componentId: componentId, name: name, type: type, }, }) }) // console.log('[Tracking] Components detected:', components.length, components); if (components.length > 0) { window.digitalData.component = components } else { // console.log('[Tracking] No components found') } } function tryDetectComponentsWithDelay(retries = 5, delay = 1000) { if (retries <= 0) return if (document.readyState !== 'complete') { return setTimeout(() => tryDetectComponentsWithDelay(retries - 1, delay), delay) } if (!window.digitalData.component || window.digitalData.component.length === 0) { detectComponents() if (!window.digitalData.component || window.digitalData.component.length === 0) { setTimeout(() => tryDetectComponentsWithDelay(retries - 1, delay), delay) } } } function onDomReady() { //Call detect Page Details after DOM is loaded setTimeout(() => { detectPageDetails(); // Detect Components with Delay tryDetectComponentsWithDelay(); analyticsTrack('pageview'); }, 3000); setTimeout(() => { checkCookies(); }, 5000); const checkPathForJobSearch = window.location.pathname; if (checkPathForJobSearch.includes('/search-results')) { setTimeout(() => { // console.log('Job search Page') performJobSearchAnalytics(); analyticsTrack('jobsearch'); }, 4000); } if (checkPathForJobSearch.includes('/job/')) { // console.log('View') setTimeout(() => { performJobViewAnalytics(); analyticsTrack('jobViewed'); }, 4000); } //Custom Logic created document.addEventListener('click', function (e) { let id = e.target.getAttribute('id'); let className = e.target.getAttribute('class'); if (className && className.includes('save-preference-btn-handler') || (id !== undefined && (id === 'onetrust-accept-btn-handler' || id === 'onetrust-reject-all-handler' || id === 'accept-recommended-btn-handler'))) { checkCookies(); } const checkPathForJobSearch = window.location.pathname; if (checkPathForJobSearch.includes('/search-results')) { setTimeout(() => { // console.log('Job search Page') performJobSearchAnalytics(); analyticsTrack('jobsearch'); }, 4000); } const clickedEl = e.target.closest('a, button') if (!clickedEl) return const ariaLabel = clickedEl.getAttribute('aria-label') || '' const textContent = clickedEl.textContent.trim().replace(/\s+/g, ' ') const name = (ariaLabel || textContent || 'Unnamed').replace(/^\d+\s+/, '').trim() // if (textContent != undefined && textContent != null && textContent == 'View Profile') { // analyticsTrack('viewprofile'); // } // if (textContent != undefined && textContent != null && textContent == 'Apply Now') { // analyticsTrack('applynow'); // } const inHeader = clickedEl.closest('header') const inFooter = clickedEl.closest('footer') let prefix = '' if (inHeader) prefix = 'header_' else if (inFooter) prefix = 'footer_' const componentId = prefix + name const componentExists = Array.isArray(window.digitalData.component) && window.digitalData.component.some(c => c.componentInfo.componentId === componentId) if (componentExists) { publishEvent(componentId, 'Click') if (textContent != undefined && textContent != null && textContent == 'View Profile') { analyticsTrack('viewprofile'); } if (textContent != undefined && textContent != null && textContent == 'Apply Now') { analyticsTrack('applynow'); } } else { // console.log('[Tracking] Click on unknown component:', name) } }); } function publishEvent(cmpID, action) { var eventName = 'None'; var componentName = 'None'; var componentType = 'None'; var editedLinkId = ' None'; for (var index = 0; index < window.digitalData.component.length; ++index) { var componentInfo = window.digitalData.component[index].componentInfo; if (cmpID === componentInfo.componentId && action === 'Click') { eventName = 'Click on clickable ' + componentInfo.type; componentName = componentInfo.name; componentType = componentInfo.type; } } var componentDetails = componentList[cmpID]; if (componentDetails) { componentType = componentDetails.type; componentName = componentDetails.name; editedLinkId = componentDetails.linkId; } var event = { eventInfo: { componentId: cmpID, type: action, timeStamp: new Date(), eventName: eventName, componentType: componentType, componentName: componentName, linkId: editedLinkId, }, }; var componentClick = new CustomEvent('componentClick', { detail: { componentClick: { componentId: cmpID, type: action, timeStamp: new Date(), eventName: eventName, componentType: componentType, componentName: componentName, linkId: editedLinkId, }, }, }); pushData(event, componentClick); } function pushData(data, componentClick) { if (typeof window.digitalData != 'undefined') { if (data.hasOwnProperty('componentInfo')) { window.digitalData.component = window.digitalData.component.filter( function (item) { return ( data.componentInfo.componentId !== item.componentInfo.componentId ); } ); window.digitalData.component.push(data); } else { window.digitalData.event = data; if (typeof componentClick != 'undefined') { document.body.dispatchEvent(componentClick); } } } } function analyticsTrack(msg) { const w = window; if ( w && w._satellite && w._satellite.track && typeof w._satellite.track === 'function' ) { w._satellite.track(msg); } } function checkCookies() { var consentGroup = window.OnetrustActiveGroups; if (consentGroup) { consentGroup = consentGroup.split(',').filter(element => element != ''); const consent = { any: consentGroup.length === 1 ? false : true, constentGroups: window.OnetrustActiveGroups, functional: consentGroup.includes('3') ? true : false, gdprEnabled: true, isAny: consentGroup.length === 1 ? false : true, isFunctionalAllowed: consentGroup.includes('3') ? true : false, isNone: consentGroup.length === 1 ? true : false, isPerformanceAllowed: consentGroup.includes('2') ? true : false, isSocialAllowed: false, isTargetingAllowed: consentGroup.includes('4') ? true : false, none: consentGroup.length === 1 ? true : false, performance: consentGroup.includes('2') ? true : false, social: false, targeting: consentGroup.includes('4') ? true : false } window.digitalData.user = { consent: consent }; } } function performJobSearchAnalytics() { // Select the element using querySelector and the attribute selector const element = document.querySelector('[data-ph-at-id="search-page-top-job-count"]'); // Get the text content of the selected element const searchRecord = element ? element.textContent : null; //console.log(searchRecord); //Fillter (Location Search Radius) const sliderElement = document.querySelector('.noUi-handle-lower'); const location_search_radius = sliderElement.getAttribute('aria-valuetext'); // console.log(location_search_radius); const frequencySelect = document.querySelector('#frequency'); // Get the value of the selected option const frequencySelectedValue = frequencySelect ? frequencySelect.value : null; // Log the selected value // console.log(frequencySelectedValue); //Area of Expertise Search filter let filter = ""; const searchTermInput = document.querySelector('#typehead'); // Get the value of the selected input element const searchTermInputValue = searchTermInput ? searchTermInput.value : ''; const locationInput = document.querySelector('#locationInput_0'); // Get the value of the selected input element const inputValue = locationInput ? locationInput.value : null; if (inputValue != undefined && inputValue != '' && inputValue != null) { filter = appendFilterPart(filter, "Location", inputValue); } if (location_search_radius != undefined && location_search_radius != '') { filter = appendFilterPart(filter, "Location Search Radius", location_search_radius); } const areaofExpertiseFilter = getSelectedValues('[data-ph-at-facetkey="facet-category"]', 'data-ph-at-text'); // console.log(areaofExpertiseFilter); if (areaofExpertiseFilter != undefined && areaofExpertiseFilter != '') { filter = appendFilterPart(filter, "Area of Expertise", areaofExpertiseFilter); } //Country Search filter const countryListFilter = getSelectedValues('[data-ph-at-facetkey="facet-country"]', 'data-ph-at-text'); // console.log(countryListFilter); if (countryListFilter != undefined && countryListFilter != '') { filter = appendFilterPart(filter, "Country", countryListFilter); } //State / Province //Country Search filter const stateListFilter = getSelectedValues('[data-ph-at-facetkey="facet-state"]', 'data-ph-at-text'); // console.log(stateListFilter); if (stateListFilter != undefined && stateListFilter != '') { filter = appendFilterPart(filter, "State", stateListFilter); } //City const cityListFilter = getSelectedValues('[data-ph-at-facetkey="facet-city"]', 'data-ph-at-text'); // console.log(cityListFilter); if (cityListFilter != undefined && cityListFilter != '') { filter = appendFilterPart(filter, "City", cityListFilter); } //Remote Job const remoteJobListFilter = getSelectedValues('[data-ph-at-facetkey="facet-remote"]', 'data-ph-at-text'); // console.log(remoteJobListFilter); if (remoteJobListFilter != undefined && remoteJobListFilter != '') { filter = appendFilterPart(filter, "Remote Job", remoteJobListFilter); } //Employment Type const employmentTypeListFilter = getSelectedValues('[data-ph-at-facetkey="facet-employmentType"]', 'data-ph-at-text'); // console.log(employmentTypeListFilter); if (employmentTypeListFilter != undefined && employmentTypeListFilter != '') { filter = appendFilterPart(filter, "Employment Type", employmentTypeListFilter); } //Job Level const jobLevelListFilter = getSelectedValues('[data-ph-at-facetkey="facet-jobLevel"]', 'data-ph-at-text'); // console.log(jobLevelListFilter); if (jobLevelListFilter != undefined && jobLevelListFilter != '') { filter = appendFilterPart(filter, "Job Level", jobLevelListFilter); } //Job Type const jobTypeListFilter = getSelectedValues('[data-ph-at-facetkey="facet-type"]', 'data-ph-at-text'); // console.log(jobTypeListFilter); if (jobTypeListFilter != undefined && jobTypeListFilter != '') { filter = appendFilterPart(filter, "Job Type", jobTypeListFilter); } //Unit const unitFilter = getSelectedValues('[data-ph-at-facetkey="facet-unit"]', 'data-ph-at-text'); // console.log(unitFilter); if (unitFilter != undefined && unitFilter != '') { filter = appendFilterPart(filter, "Unit", unitFilter); } var inputElement = document.getElementById('subSearchTextbox'); // Get the value from the input element var inputValuekeywords = inputElement.value; if (inputValuekeywords != undefined && inputValuekeywords != '') { filter = appendFilterPart(filter, "keywords", inputValuekeywords); } const nameSearch = "Job Search"; const searchTerm = searchTermInputValue; const typedSearchTerm = searchTermInputValue; const numberOfResults = searchRecord; const searchObj = createSearchObject(nameSearch, searchTerm, typedSearchTerm, filter, numberOfResults, frequencySelectedValue); // console.log(searchObj); window.digitalData.search = searchObj; function getSelectedValues(selector, attribute) { // Select all elements based on the provided selector const elements = document.querySelectorAll(selector); // Initialize an array to store the selected values const selectedValues = []; // Iterate over the elements and check if they are selected (checked) elements.forEach(element => { if (element.checked) { // Extract the relevant information from the element using the provided attribute const value = element.getAttribute(attribute); // Add the extracted information to the selectedValues array selectedValues.push(value); } }); // Join the selected values into a string separated by commas return selectedValues.join(','); } function createSearchObject(name, searchTerm, typedSearchTerm, filter, numberOfResults, frequencySelectedValue) { // Initialize the search object with mandatory properties const searchObject = { name: name, searchTerm: searchTerm, typedSearchTerm: typedSearchTerm, numberOfResults: numberOfResults, filter: filter }; if (frequencySelectedValue) { if (frequencySelectedValue == 1) { searchObject.alert = 1; } else if (frequencySelectedValue == 2) { searchObject.alert = 7; } else if (frequencySelectedValue == 3) { searchObject.alert = 30; } } return searchObject; } function appendFilterPart(filter, key, value) { if (value !== undefined && value !== '') { // Append with '|' only if filter is not empty if (filter) { filter += '|'; } filter += `${key}:${value}`; } return filter; } } function performJobViewAnalytics() { var locationElement = document.querySelector('span.location'); var locationText = locationElement.querySelector('span.phw-g-text-default-light').textContent.trim(); if (locationText.includes("Location")) { locationText = locationText.replace("Location: ", ""); } var jobLevelElement = document.querySelector('span.jobLevel'); var jobLevelText = jobLevelElement.querySelector('span.phw-g-text-default-light').textContent.trim(); if (jobLevelText.includes("undefined")) { jobLevelText = jobLevelText.replace("undefined: ", ""); } var typeElement = document.querySelector('span.type'); var typeText = typeElement.querySelector('span.phw-g-text-default-light').textContent.trim(); if (typeText.includes("widget")) { typeText = typeText.replace("widget: ", ""); } var jobIdElement = document.querySelector('span.jobId'); var jobIdText = jobIdElement.querySelector('span.phw-g-text-default-light').textContent.trim(); // console.log(jobIdText); if (jobIdText.includes("Job ID")) { jobIdText = jobIdText.replace("Job ID: ", ""); } var employmentTypeElement = document.querySelector('span.employmentType'); var employmentTypeText = employmentTypeElement.querySelector('span.phw-g-text-default-light').textContent.trim(); // console.log(employmentTypeText); if (employmentTypeText.includes("undefined")) { employmentTypeText = employmentTypeText.replace("undefined: ", ""); } var jobTitleElement = document.querySelector('h1.job-title'); var jobTitleText = jobTitleElement.textContent.trim(); var remoteElement = document.querySelector('span.remote'); var remoteText = remoteElement.querySelector('span.phw-g-text-default-light').textContent.trim(); // console.log(remoteText); if (remoteText.includes("Remote")) { remoteText = remoteText.replace("Remote: ", ""); } var categoryElement = document.querySelector('span.category'); var categoryText = categoryElement.querySelector('span.phw-g-text-default-light').textContent.trim(); // console.log(categoryText); if (categoryText.includes("Category")) { categoryText = categoryText.replace("Category: ", ""); } var unitElement = document.querySelector('span.unit'); var unitText = unitElement.querySelector('span.phw-g-text-default-light').textContent.trim(); // console.log(unitText); if (unitText.includes("undefined")) { unitText = unitText.replace("undefined: ", ""); } var employingEntityElement = document.querySelector('span.employingEntity'); var employingEntityText = employingEntityElement.querySelector('span.phw-g-text-default-light').textContent.trim(); if (employingEntityText.includes("undefined")) { employingEntityText = employingEntityText.replace("undefined: ", ""); } const searchObj = createSearchViewObject(locationText, jobLevelText, categoryText, unitText, employingEntityText, typeText, remoteText, employmentTypeText, jobIdText, jobTitleText); // console.log(searchObj); window.digitalData.search = searchObj; function createSearchViewObject(locationText, jobLevelText, categoryText, unitText, employingEntityText, typeText, remoteText, employmentTypeText, jobIdText, jobTitleText) { // Initialize the search object with mandatory properties const searchObject = { location: locationText, jobLevel: jobLevelText, areaOfExp: categoryText, unit: unitText, entity: employingEntityText, jobType: typeText, remoteJob: remoteText, emplType: employmentTypeText, jobId: jobIdText, selectedItem: jobTitleText }; return searchObject; } } function detectPageDetails() { if (!window.digitalData || window.digitalData.length === 0) { const currentPath = location.pathname.split('/').filter(Boolean); let pageName; const pathWithoutLocale = currentPath.slice(2); if (pathWithoutLocale.length === 0) { pageName = 'Home'; } else { const lastSegment = pathWithoutLocale[pathWithoutLocale.length - 1]; const cleaned = lastSegment.replace(/[\r\n_-]+/gm, ' '); pageName = /\d/.test(cleaned) && pathWithoutLocale.length > 1 ? pathWithoutLocale[pathWithoutLocale.length - 2].replace(/[\r\n_-]+/gm, ' ') : cleaned; } if (pathWithoutLocale[0] === 'job') { pageName = 'jobDetails'; // console.log('[Tracking] pageName:', pageName); } const selectedCountryElement = document.querySelector('.selected-country'); let countryValue = selectedCountryElement?.textContent?.trim() || 'unknown'; if (countryValue === 'United States') { countryValue = 'US'; } const langPart = currentPath[1]?.toLowerCase() || ''; const regionPart = currentPath[0]?.toLowerCase() || ''; let language = 'unknown'; if (langPart === 'en') { language = regionPart === 'us' ? 'en_US' : 'en_GB'; } else if (langPart) { language = `${langPart}_${langPart.toUpperCase()}`; } // console.log('[Tracking] language:', language, 'country:', countryValue); const isInternalUser = document.getElementsByClassName('empLogoutLink').length > 0; const normalizedCountry = countryValue.replace(/\s+/g, ''); const isHome = pathWithoutLocale.length === 0; const pageId = `/${normalizedCountry}/${isHome ? 'home' : pathWithoutLocale.join('/')}`; window.digitalData = { page: { pageInfo: { pageId: pageId, pageName: pageName, fullURL: window.location.href, URL: window.location.href.replace(window.location.search, ''), referringURL: document.referrer, language: language, country: countryValue, siteSection: countryValue, isInternal: isInternalUser, }, attributes: { organisationalEntity: 'azcom (careers)', }, }, }; } } } // Run init once DOM is ready (or immediately if it already is) if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); window.addEventListener('load', init); } })();