Hi guys , I have a problem that My custom code didn't work in data collection and I don't know why
Here is the code :
var ArticleCheckBox = document.querySelectorAll('[id^="article"]');
ArticleCheckBox.forEach(function(element){
element.addEventListener('click',function(){
var event = {eVar71: element.getAttribute("name"),};
trigger(event);
});
});
Solved! Go to Solution.
Views
Replies
Total Likes
I believe you're doing it wrongly. Here's my suggestion to update the Rule:
So what's happening here is that you're letting Launch detect the click for you, and when it does, you're instructing it to set eVar71 to the clicked element's "name" attribute.
Hope that helps!
Hello @Wasai
Are you getting any errors in the console or the event isn't triggering?
A good way to troubleshoot is by writing logs with the console.log in the custom code and checking at which line it is breaking.
Views
Replies
Total Likes
I add console.log in the code but the console didn't show anything or warning I think because of my code didn't trigger so it may not show message on the console
var ArticleCheckBox = document.querySelectorAll('[id^="article"]');
console.log("123")
ArticleCheckBox.forEach(function(element){
console.log("456")
element.addEventListener('click',function(){
var event = {eVar71: element.getAttribute("name"),};
trigger(event);
});
});
Views
Replies
Total Likes
I believe you're doing it wrongly. Here's my suggestion to update the Rule:
So what's happening here is that you're letting Launch detect the click for you, and when it does, you're instructing it to set eVar71 to the clicked element's "name" attribute.
Hope that helps!