I've added the event Core - Data Element Change and in custom code consoling it out. The data element name is 'form Abandonment' and js object is digitalData.form.formAbandonment
if(digitalData.form.formAbandonment != ""){
console.log("Refresh case:"+_satellite.getVar("form Abandonment"));
return true;
} else {
console.log("Not updated");
return false;
}
I tried consoling out the same value in datalayer and I'm getting the right values for both js and satellite object. The formAbandonment is set on unload event.
$(window).on( "unload", function() {
formArray['formAbandonment'] = fieldName;
});
)};
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
What is most likely happening is that there's a "race condition" between when your digitalData.form.formAbandonment gets set vs when the browser has already unloaded and is navigating to the next page. You can verify if this is the case with the Adobe Experience Platform Debugger's Events panel.
With window's unload function, one "trick" I've used that works pretty consistently is to perform the Rule's action within a condition. Basically, run the action's custom code in a condition, and make sure the last line is "return true;".
Views
Replies
Total Likes
What is most likely happening is that there's a "race condition" between when your digitalData.form.formAbandonment gets set vs when the browser has already unloaded and is navigating to the next page. You can verify if this is the case with the Adobe Experience Platform Debugger's Events panel.
With window's unload function, one "trick" I've used that works pretty consistently is to perform the Rule's action within a condition. Basically, run the action's custom code in a condition, and make sure the last line is "return true;".
Views
Replies
Total Likes
The event is not getting triggered at all it seems to be. No traces in the debugger. Yeah I've used some condition in rules action but since the data element change is not triggering it isn't working. Also the browser unload only happens after every line inside it's executed. Even I tried with a delay after variable set in js, still the same.
Views
Replies
Total Likes
@jezwna Data Element Change event might not be the best for you.
Try using a Custom Code event. In there, you can use:
window.addEventListener('beforeunload', function (event) {
trigger(); // REQUIRED
});
Then, you can read from your data element in a condition or action.
Views
Replies
Total Likes
@yuhuisg Is it a good practice to set the variables and send s.tl() from the datalayer itself, I mean inside the unload event. Tried with that and it works. Just need to make sure if it could be done.
Views
Replies
Total Likes
Views
Replies
Total Likes
@yuhuisg Whatever written inside the unload event gets executed unless it's an async activity. But I asssume there was this race condition before, when I tried to set the js variable inside unload vs the unload event. After setting the js variable, currently I'm setting evars, props and events inside the unload event in datalayer. But this seems bit odd doing this in datalayer. That's the concern was about.
s.eVar21 = fieldName;
s.prop29 = s.eVar21;
s.events = "event3";
s.tl();
s.clearVars();
Your suggestion was to add a custom code event and trigger(), right! I'll check with that. Thanks.
Views
Replies
Total Likes
@yuhuisg There's some other issue doing it this way, the one you shared and the one I was on. When I check the network requests it shows pending, none of the requests on unload are getting completed.
Views
Replies
Total Likes
Views
Replies
Total Likes