window.dataLayer = window.dataLayer || []; var basicAnalyticsData = { country: "en-GB", segmentName: "PCO", pageType: "search" ,numberOfSearchResults: 21 ,event: "gaGenericEvent", eventCategory: "Search", eventAction: "Internal", eventLabel: "K-Obiol", eventCustom: "21" }; var responsiveBreakpoints = [ { mediaQuery: '(max-width: 639px)', name: 'xs' }, { mediaQuery: '(min-width: 640px) and (max-width: 1079px)', name: 'sm' }, { mediaQuery: '(min-width: 1080px) and (max-width: 1599px)', name: 'md' }, { mediaQuery: '(min-width: 1600px) and (max-width: 2560px)', name: 'lg' }, { mediaQuery: '(min-width: 2561px)', name: 'xl' }, ]; if (typeof basicAnalyticsData === 'object') { basicAnalyticsData = decodeCharacters(basicAnalyticsData); } basicAnalyticsData.responsiveBreakpoint = determineBreakpoint(); try { window.dataLayer.push(basicAnalyticsData); } catch (e) { console.warn(e); } function decodeCharacters(json) { var decodedJSON = JSON.stringify(json).replace(/&#(\d+);/g, function (p1, p2) { return String.fromCharCode(p2) }); return JSON.parse(decodedJSON); } function determineBreakpoint() { return responsiveBreakpoints.filter(function(breakpoint) { return window.matchMedia(breakpoint.mediaQuery).matches === true })[0].name; }