This text is not a standard press release, but a JavaScript snippet embedded in the GU official e-commerce site. Below is an explanation of its functionality.
### Summary of Functionality
The script's primary purpose is to set up a sophisticated tracking and analytics system. It distinguishes between users browsing on a standard web browser versus those using GU's native iOS or Android applications. This allows for tailored analytics and user experience.
### Detailed Breakdown
1. **Mobile App Detection**: The code checks the browser's `userAgent` string for patterns like `/gu ios application/i` or `/gu android application/i`. ```javascript var GU_MOBILEAPP_PRESENT = false; var guIOSPattern = /gu ios application/i; var guAndroidPattern = /gu android application/i; var userAgent = navigator.userAgent; ``` If a match is found, it dynamically loads a specific JavaScript file (`mobileapp.js`) and sets a flag `GU_MOBILEAPP_PRESENT = true`.
2. **Analytics Event Logging**: It defines functions `logEvent` and `setUserProperty` that act as a bridge to the native app's analytics framework (Firebase Analytics). This allows the website content (when viewed inside the app) to send tracking data to the same analytics backend as the native app itself. ```javascript function logEvent(name, params) { if (window.AnalyticsWebInterface) { // Android window.AnalyticsWebInterface.logEvent(name, JSON.stringify(params)); } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.firebase) { // iOS var message = { command: 'logEvent', name: name, parameters: params }; window.webkit.messageHandlers.firebase.postMessage(message); } } ```
3. **Google Tag Manager (GTM) Integration**: The script initializes Google's Tag Manager with the ID `GTM-NMD6F5H`. This is a standard method for managing various tracking tags (like Google Analytics, marketing pixels, etc.) without modifying the site's code for each one. ```javascript (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;var n=d.querySelector('[nonce]'); n&&j.setAttribute('nonce',n.nonce||n.getAttribute('nonce'));f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-NMD6F5H'); ```
4. **Real User Monitoring (RUM) with Boomerang**: The script includes a snippet for Boomerang by Akamai mPulse. This tool is used for Real User Monitoring, which collects performance metrics (like page load times, network latency) directly from end-users' browsers. This helps GU understand and optimize the real-world performance of their website. ```javascript // window.BOOMR_API_key="9VM32-GXRFY-Y2BSZ-NBJZQ-HQ2VR" // ... (Boomerang loader code) ... ```
In essence, this code shows that GU is heavily invested in a data-driven approach to understanding its customers and optimizing its digital platforms.
FACT BOX
- Source: PR Times
- Category: News
- Organizations: Google / Akamai