Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.
SOLVED

What is the clearVars() equivalent for the webSDK?

Avatar

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.

 

Dave_Hamel_2024_0-1715714020942.png

 

Thanks!

 

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Yeah, the video is built upon the previous one which describes the XDM setup Jim is suggestion.

  • a WebSDK XDM object that hold the global data
  • a WebSDK Variable that can be fully reset and set in the individual context of the rule e.g., for a specific user interaction
  • a merged object (Core extension) that is merging the global and the variable XDM object. This is the data that is send in the WebSDK requests

https://www.youtube.com/watch?v=PdV8c2lmd-0

 

Cheers

Cheers from Switzerland!


View solution in original post

3 Replies

Avatar

Adobe Champion

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:

dataLayer.push({
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

https://experienceleague.adobe.com/en/docs/analytics/implementation/aep-edge/web-sdk/overview

Hope this helps!






Avatar

Correct answer by
Community Advisor

Yeah, the video is built upon the previous one which describes the XDM setup Jim is suggestion.

  • a WebSDK XDM object that hold the global data
  • a WebSDK Variable that can be fully reset and set in the individual context of the rule e.g., for a specific user interaction
  • a merged object (Core extension) that is merging the global and the variable XDM object. This is the data that is send in the WebSDK requests

https://www.youtube.com/watch?v=PdV8c2lmd-0

 

Cheers

Cheers from Switzerland!