I would like to track when a Form is Submitted from profiles so that I can update the Properties. For example, If a user clicks on an action of a popup form, I want to be able to track and see if they have clicked that action and then update their profile with the with a specific Tag.
I have seen the URL Articles here: https://help.klaviyo.com/hc/en-us/articles/360003953111-Adding-Custom-JavaScript-Events-to-Forms. Please let me know if this Code will work:
<script>
window.addEventListener("klaviyoForms", function(e) {
if (e.detail.type == 'open' || e.detail.type == 'embedOpen') {
_learnq.push(s'track', 'Viewed Form - Tracked Profile', {
'formId' : e.detail.formId
}]);
}
if (e.detail.type == 'submit' || e.detail.type == 'redirectedToUrl') {
_learnq.push(s'track', 'Submitted Form - Tracked Profile', {
'formId' : e.detail.formId
}]);
});
</script>