Expand my Community achievements bar.

What is the clearVars() equivalent for the webSDK?


Level 2

I am playing around with the webSDK, and noticed that it is not clearing the vars after each action.

In this example, I have three events that occurred.  First was a page view which includes the custom event1, the second is a "click to call" which is event11 and finally a "chat" event which is event20.


Each of these events are in different rules which are triggered by different data layer pushes. In the last event, chat, only event20 is set in the xdm.variable.content data element.  How can I wipe out the others?  I don't want them over counting.







Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies


Level 2

Hi @Dave_Hamel_2024 ,


The WebSDK is designed to clear XDM data automatically after each sendEvent call, but sometimes you might need to take extra steps to ensure this happens, especially if you're noticing that variables from previous events are sticking around.


You can manually reset variables in your data layer push. For example, when you push the data for a chat event, you can explicitly set the previous event variables to null, This ensures that the previous variables are cleared and only the new event data is sent.

Sample Code:

event: 'chat', 
xdm: { 
_experience: { 
analytics: { 
customDimensions: { 
props: { 
prop10: null // Clear the custom prop if needed 
event1to100: { 
event1: { value: null }, // Clear event1 
event11: { value: null }, // Clear event11 
event20: { value: "1" } // Set event20 
} });


Also, you can set up rules to clear variables.

Log in to Adobe Experience Platform Data Collection, navigate to your tag property, and go to the Rules tab. Edit an existing rule or create a new one, and under Actions, add a new action with the Adobe Analytics extension. Set the action type to “Clear Variables.” This helps to reset the variables based on the conditions you set in the rule.

By manually clearing the variables or setting up appropriate rules, you can manage your event data effectively and avoid overcounting.


Ref: https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/functions/clearvars


Hope this helps!