Understanding and implementing effective website tracking and user engagement tools is crucial for optimizing your digital strategy. Let’s explore how to integrate tools like Google Tag Manager, facebook Pixel, and Survicate to gain valuable insights into your audience and improve their experience.
First, it’s vital to determine your user’s subscription status and geolocation. This information allows for personalized experiences and targeted marketing efforts. Typically, this involves checking for a prime_user_status variable and utilizing the window?.geoinfo?.CountryCode to identify the user’s location, defaulting to ‘IN’ if unavailable.
Next, you can leverage visitor traits through platforms like Survicate. specifically, toi_user_subscription_status and toi_user_geolocation are set as visitor traits, providing a complete user profile. This data is then sent to Survicate using w._sva.setVisitorTraits.
If Survicate is already initialized (w._sva && w._sva.setVisitorTraits), the attributes are set immediately. Otherwise, an event listener is added to ensure the attributes are set once Survicate is fully loaded (“SurvicateReady”).this ensures data accuracy and avoids errors.
Afterward, the Survicate JavaScript is dynamically loaded into your webpage. A script tag is created,its source set to the Survicate workspace URL,and it’s asynchronously inserted before the first script tag. Asynchronous loading prevents the script from blocking page rendering, improving user experience.
Now, let’s discuss integrating event tracking based on campaign configurations. Initially, a check is performed to see if campaign settings are available within a configuration object (f.toiplus_site_settings). This includes flags for Google and Facebook campaign activity.
If the configuration is available and the user isn’t a prime subscriber, Google and Facebook event tracking scripts are loaded, along with the Survicate JavaScript. This streamlined approach ensures relevant tracking is activated for non-subscribers.
However,if the configuration isn’t immediately available,or if the user is a prime subscriber,a request is made to a Jarvis endpoint to retrieve the site settings. This endpoint provides details on campaign activity and allowed Survicate sections.
Here’s what works best: the allowedSurvicateSections are dynamically adjusted based on whether the user is in a prime layout. Prime users receive a different set of allowed sections (config?.allowedSurvicatePrimeSections) compared to standard users (config?.allowedSurvicateSections). This allows for tailored surveys and feedback collection.
I’ve found that loading events in a modular fashion is key to maintaining a clean and efficient codebase. Google Tag Manager (Gtag) events are loaded using the loadGtagEvents function, while Facebook Pixel events are loaded with loadFBEvents.
the loadSurvicateJs function handles the integration of Survicate, passing the appropriate allowed sections for targeted surveys. This modularity makes it easier to manage and update tracking configurations without impacting other parts of your website.
to summarize, here’s a breakdown of the key steps:
* Determine User Status: Identify if the user is a prime subscriber.
* Geolocation: Detect the user’s country code.
* Set Visitor Traits: Send subscription status and geolocation to Survicate.
* Load Tracking Scripts: Dynamically load Google Tag Manager,Facebook Pixel,and Survicate.
* Configuration Management: Retrieve campaign settings from a central source (Jarvis).
* Modular Loading: Load events in a modular fashion for maintainability.
By following these steps, you can effectively implement a robust tracking and engagement strategy, gaining valuable insights into









