New Delhi, India – A new JavaScript code snippet has been implemented to enhance user engagement and data collection across Times Apps properties. The code, designed to be universally available, aims to dynamically load marketing and analytics tools based on user attributes and site configurations.
The core functionality of the script revolves around the `TimesApps.toiPlusEvents` function, which acts as a central point for initializing various tracking and survey functionalities. This function checks for the availability of site-specific settings, denoted by `toiplus_site_settings`, and user subscription status, indicated by `window.isPrime`.
If essential site settings are present and the user is not a prime subscriber, the script proceeds to load Google Tag Manager (gtag) events and Facebook Pixel (fbevents) based on the `isGoogleCampaignActive` and `isFBCampaignActive` flags respectively. Additionally, it integrates Survicate, a customer feedback platform, by loading its JavaScript if the `allowedSurvicateSections` are configured.
In scenarios where the initial site settings are not available or the user is a prime subscriber,the script fetches these configurations from a remote endpoint: `https://jarvis.indiatimes.com/v1/feeds/toi_plus/site_settings/643526e21443833f0c454615?db_env=published`. this dynamic fetching mechanism ensures that the latest campaign and survey configurations are always utilized. The `allowedSurvicateSections` are then persistent based on whether the user is accessing a prime user layout.
The Survicate integration is handled by a dedicated `loadSurvicateJs` function. This function ensures that the Survicate script is loaded asynchronously.It also includes logic to set visitor traits, such as user subscription status and geolocation, using the `_sva.setVisitorTraits` method.If the Survicate object (`_sva`) is not immediately available, the script sets up an event listener for the `SurvicateReady` event to ensure the traits are set once the platform is initialized. The Survicate script itself is sourced from `https://survey.survicate.com/workspaces/0be6ae9845d14a7c8ff08a7a00bd9b21/web_surveys.js`.
This complete approach allows times Apps to tailor the user experience and marketing efforts by leveraging real-time data and user segmentation, ensuring that relevant campaigns and feedback mechanisms are activated efficiently.