New Delhi, India – The Times of India has implemented a new JavaScript code snippet designed to enhance user engagement and data collection across its digital platforms. The code, which appears to be part of a broader strategy to personalize user experiences and track campaign effectiveness, integrates with third-party services like Google Tag Manager (GTM), Facebook Pixel, and Survicate.
the script, loaded asynchronously, first checks for the existence of specific configuration settings within the `window.f` object, especially `toiplus_site_settings`, and flags related to Google and Facebook campaign activity.It also assesses the user’s subscription status, identifying them as a “prime user” if `window.isPrime` is true, and checks for a specific layout indicator, `window.isPrimeUserLayout`.
If the initial configuration is available and the user is not a prime subscriber,the script proceeds to load Google Tag Manager events,Facebook Pixel events,and Survicate javascript,contingent on the campaign flags and allowed Survicate sections respectively. These functionalities are triggered by dedicated functions: `loadGtagEvents`, `loadFBEvents`, and `loadSurvicateJs`.
In scenarios where the initial configuration is not present or the user is identified as a prime subscriber, the script fetches site settings from a specified Jarvis API endpoint: `https://jarvis.indiatimes.com/v1/feeds/toi_plus/site_settings/643526e21443833f0c454615?db_env=published`. This dynamic fetching allows for real-time updates to campaign settings and Survicate section permissions. The `getFromClient` function is utilized for this asynchronous data retrieval.
Upon successful retrieval of data from Jarvis, the script determines the appropriate Survicate sections to enable based on the `isPrimeUserLayout` flag. If `isPrimeUserLayout` is true, it uses `config?.allowedSurvicatePrimeSections`; or else, it defaults to `config?.allowedSurvicateSections`. Afterward, it loads the GTM and Facebook Pixel events, along with the Survicate JavaScript, based on the fetched campaign activation flags and the determined Survicate sections.
The Survicate integration includes a mechanism to set visitor traits, such as subscription status and geolocation, when the Survicate object is ready. If the `_sva` object and its `setVisitorTraits` method are available, the attributes are set directly. Or else, an event listener is attached to the `SurvicateReady` event to ensure the attributes are set once the survicate library is fully initialized.
This comprehensive approach suggests The Times of India is actively leveraging user data and campaign performance metrics to refine its digital strategy, aiming to deliver more targeted content and advertising experiences to its diverse readership.