new delhi – A recent update to the timesapps JavaScript library introduces enhanced tracking and user engagement capabilities, including integration with Survicate, google Analytics (gtag.js), and Facebook Pixel.
the updated code allows for dynamic loading of these services based on user subscription status and geographical location. If a user is identified as a “prime” subscriber, their subscription status is set to ‘paid’; otherwise, it defaults to ‘free’.Geolocation data is also captured, defaulting to ‘IN’ if not or else specified.
The Survicate integration is designed to be activated once the Survicate library is ready. The script for Survicate is fetched from a dedicated URL,ensuring its asynchronous loading to avoid blocking page rendering.
The TimesApps.toiPlusEvents function serves as the primary entry point for these integrations. It checks for the availability of site settings, specifically `isFBCampaignActive` and `isGoogleCampaignActive`. if these settings are present and the user is not a prime subscriber, the Google and Facebook tracking scripts are loaded directly, along with Survicate if permitted for specific sections.
In scenarios where the initial site settings are not available or the user is a prime subscriber, the system fetches these settings from a remote endpoint at `https://jarvis.indiatimes.com/v1/feeds/toi_plus/site_settings/643526e21443833f0c454615?db_env=published`. This dynamic fetching allows for real-time configuration updates. The Survicate integration, in this case, is further refined based on whether the user is accessing a prime user layout, selecting appropriate sections for tracking.