28-03-2022
- Mark as New
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
I believe there is a functionality that allows you to do clean tracking without necessary having to use clearVars or custom code in callbacks.
There is a feature in Adobe Analytics that is called variable Override: https://experienceleague.adobe.com/docs/analytics/implementation/js/overrides.html?lang=en
You can pass an object to the s.t and s.tl code which the configuration you want just in this call. Once the call is sent the s object does not inherit the value from the override object.
So if you use:
var analyticsConfig = {
pageName: "My test page name",
eVar1: "New value 123",
prop1: "ABC"
}
s.t(analyticsConfig)
You will see that you analytics call will contain only config from your analyticsConfig object.
Then check in the developer console and type s.pageName and notice you should see undefined, as the values from your override object did not update the s object. This is a much better solution.
As Adobe Launch support ES6 you can also configure a base object that will be merged to custom object so you are sure default variables to always be set on the call:
var base = {
pageName: "abc",
eVar3: "default"
}
var customConfig = {
eVar1: "123",
prop1: "abc"
}
s.t({
...base,
...customConfig
}); //use spread operatorSo obviously we will create dataElements here to get base object and custom object.
This is a better solution as you can make sure that your call will only contain the values you need and you do not need to worry to clean up after yourself.