Situation: I have created a 6 page micorsite for lead generation. The site has the ability to take in lead source variables that we pass through and I was looking to add in a backup as we have seen some gaps recently with this variable. To fix the issue, I added in some JS to capture the tracking tag from a link and pass it through all the pages until they hit submit on the form. To do this I had to add in an if statement to only fill the variable if it is empty/null/undefined, but my logic isnt working and its repopulating on every page. From what I can tell the IF itself isnt wrong, but when I search in the consol for the variable it doesnt appear, although it does in the AC debug mode. If the IF thinks the variableis empty, this would make sense why it is updating it constantly, but I cant figure out why its reading the variable that way. Any idea what I am doing wrong?
JS (fires onload):
function updateTrackingTag() {
var TrackingTag = document.controller.getValue('/ctx/vars/trackingtag');
if (TrackingTag !== "" || TrackingTag !== undefined || TrackingTag !== null) {
document.controller.setValue('/ctx/vars/trackingtag', TrackingTag);}
else {
document.controller.setValue('/ctx/vars/trackingtag', location.search);}
}
Views
Replies
Total Likes
Can you try changing your code to this one?.
function updateTrackingTag() {
var TrackingTag = document.controller.getValue('/ctx/vars/trackingtag');
if (TrackingTag != "" || TrackingTag != undefined || TrackingTag != null) {
document.controller.setValue('/ctx/vars/trackingtag', TrackingTag);}
else {
document.controller.setValue('/ctx/vars/trackingtag', location.search);}
}
I am assuming it is not working because of data type issue.
Thanks,
Manoj
Views
Replies
Total Likes
Views
Replies
Total Likes
Hello @bryceh57660644
follow these steps
Thanks,
Manoj
Views
Replies
Total Likes
Hi @bryceh57660644,
Were you able to resolve this query with the given solution or do you still need more help here? Do let us know.
Thanks!
Views
Replies
Total Likes
Views
Likes
Replies