This doc will walk through how to configure and control the tracking of sessions and clicks within your Search experience.
A session is defined as a set of interactions performed by a user within a given time frame. Session information is stored primarily via session storage, with session cookies used as a fallback when session storage is not available. A single session lasts as long as the browser remains open - opening a new tab creates a new session.
You can make Search "fully anonymous" by toggling both session tracking and click tracking off. This guide covers the default behavior for both, how to toggle them dynamically, and how to test your configuration.
Step 1: Default Behavior for Session Tracking
By default, session tracking is turned on. If you are integrating with a session consent management system, you will want to have session tracking off by default. The process of setting this default behavior depends on how your search experience has been created.
- If you are utilizing the Search HH Theme, set
sessionTrackingEnabledtofalsein theglobal_config.jsonfile - If you are building with the Search UI SDK, set
sessionTrackingEnabledtofalsewhen you initialize Search in JavaScript:
ANSWERS.init({
experienceKey: 'europeanAnswers',
experienceVersion: 'PRODUCTION',
locale: 'es',
sessionTrackingEnabled: false
});
Note: If you plan to toggle session tracking, it is important that session tracking is turned off by default. If it is turned on to start, then turned off dynamically, session cookies may still be used to store and pass a session ID; we do not attempt to interfere with the browser's cookies once they have already been set.
Step 2: Default Behavior for Click Tracking
By default, click tracking is turned on. To turn click tracking off by default:
If you are utilizing the Search HH Theme, there are two options:
1) Set
analyticsEventsEnabledtofalsein theglobal_config.json2) Pass the
analyticsEventsEnabledboolean to the runtime config:const RuntimeConfig = { "linkTarget": "_blank", "jwt": "81839181201siwnfoskqoi1i39", "analyticsEventsEnabled": "false" }If you are building with the Search UI SDK: set
analyticsEventsEnabledtofalsewhen you initialize Search in JavaScript:ANSWERS.init({ experienceKey: 'europeanAnswers', experienceVersion: 'PRODUCTION', locale: 'es', analyticsEventsEnabled: false });
Step 3: Setting Session Tracking Dynamically
Once session tracking is turned off by default, you have two options. The first is to simply keep it off and never turn it back on under any circumstances. However, we strongly recommend against this because session tracking significantly improves the quality of our analytics.
A better option is to toggle session tracking dynamically based on whether the user has consented to cookies. The mechanism to do this will change based on how you are integrating.
Search HH Theme Integrations
Use the runtimeConfig to turn on sessionTrackingEnabled:
If you are using the JS Snippet option, call:
AnswersExperienceFrame.runtimeConfig.set("sessionTrackingEnabled", true)If you are using a subdomain, call:
AnswersExperience.runtimeConfig.set("sessionTrackingEnabled", true)
Search UI SDK Integrations
Use the ANSWERS.setSessionsOptIn hook:
ANSWERS.setSessionsOptIn(true)
Examples
Here is an example of how you might accomplish this with a simple HTML checkbox. This can be extended to integrate with any cookie consent management system.
<label>
<input
type="checkbox"
onChange="ANSWERS.setSessionsOptIn(this.checked);"
/>
I consent to the cookie policy.
</label>
In this example, when the user checks the check box, it calls the ANSWERS.setSessionsOptIn hook to update sessionTrackingEnabled. It passes true if the box is checked, and false if it's not.
If you're using the JS Snippet option and the Search HH Theme, here's how the checkbox might function.
<label>
<input
type="checkbox"
onChange="AnswersExperienceFrame.runtimeConfig.set('sessionTrackingEnabled', this.checked)"
/>
I consent to the cookie policy.
</label>
Step 4: Setting Click Tracking Dynamically
Once click tracking is turned off by default, you have two options. The first is to simply keep it off - however, we strongly recommend against this.
Similar to session tracking, a better option is to toggle click tracking dynamically based on whether the user has consented to it. The mechanism to do this will change based on how you are integrating.
Search HH Theme Integrations
Use the runtimeConfig to turn on click tracking.
If you are using the JS Snippet option, call:
AnswersExperienceFrame.runtimeConfig.set("analyticsEventsEnabled", true)If you are using a subdomain, call:
AnswersExperience.runtimeConfig.set("analyticsEventsEnabled", true)
Search UI SDK Integrations
Use the ANSWERS.setAnalyticsOptIn hook:
ANSWERS.setAnalyticsOptIn(true)
Examples
Here is an example of how you might accomplish this with a simple HTML checkbox. This can be extended to integrate with any cookie consent management system.
<label>
<input
type="checkbox"
onChange="ANSWERS.setAnalyticsOptIn(this.checked);"
/>
I consent to the cookie policy.
</label>
In this example, when the user checks the check box, it calls the ANSWERS.setAnalyticsOptIn hook to update analyticsEventsEnabled. It passes true if the box is checked, and false if it's not. In turn, this stops any clicks from being recorded.
Step 5: Testing Your Session Tracking Configuration
After configuring your session tracking preferences, it is important to test that everything has been set up correctly. This will involve inspection of the browser developer tools as well as analytics within the platform.
Test Using Browser Developer Tools
When session tracking is enabled, information related to the active session is stored primarily in session storage and passed as a parameter in subsequent API requests. If session storage is not available, Search will fallback to dropping a session cookie that is passed back in all subsequent requests.
In order to view the information being held in session storage, inspect the page and open your browser developer tools. Navigate to the "Application" tab and select "Session Storage". When session tracking is enabled, you will see a line item that is storing a Session ID for the current session, as shown below:

As mentioned, Search will resort to dropping a session cookie in the event that session storage is unavailable for use. To check for this session cookie, navigate to the "Network" tab and select "Headers". If your browser is storing user information via session cookie, you will see one of the request headers is a cookie containing a Session ID:

If session cookies are being used by Search, you will also be able to view this cookie in the "Cookies" tab:

After disabling session tracking, confirm that the browser is not storing a Session ID value in session storage OR through a session cookie. This will ensure no session-related information is being stored while users engage with your search experience.
Test Using Search Analytics in the Platform
In addition to testing within the browser, it is important to test that your session tracking configuration is being correctly reflected in the Yext platform's analytics. When session tracking is enabled, you will notice that if you were to open your search experience and conduct 5 searches for "FAQs", your analytics will show 1 new session and 5 new searches for that search term.
In contrast, when session tracking is turned off, every search will simply be recognized as its own unique session. In this case, if you were to open your experience and conduct 5 searches for "FAQs", your analytics will show 5 new sessions and 5 new searches for that term.
Step 6: Testing Your Click Tracking Configuration
Testing Using Browser Developer Tools
When click tracking is enabled, every click within your search experience fires an event containing information about the particular action a user has taken. This event information is sent to the Yext Platform where it is logged with all other Search analytics metrics.
You can see each of these click events being fired in real time using the browser developer tools. To see this, inspect your page and navigate to the "Network" tab. In the example screenshot below, an FAQ was clicked by a user. This click event triggered related information about the action to be stored and subsequently sent to the Yext Platform. On the right, you can see that this particular click was logged as a "ROW_EXPAND" on the FAQs vertical.

After disabling click tracking, you will not see any click-related events being logged in the Network tab of the browser developer tools.
Testing Using Search Analytics in the Platform
Once click tracking has been disabled, no clicks within the search experience will be tracked in any capacity. To test this, open up your search experience and click around. Expand FAQs or click on entity titles and call-to-action buttons. After doing so, you should see that zero additional clicks have been logged in the platform.