I have created a variable in GTM code to fetch emails but It needs to collect the data from the thankyou page Script. I have used Zoho forms to do this. Can somebody help?
Here's the function I'm using:
function() {
try {
var searchEmail = function(input) {
for(i=0; i<input.length; i++) {
email = input[i].value;
if(email.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)) {
return email;
}
}
}
return searchEmail({{Form Element}});
} catch(e) {
return "";
}
}
The idea is that the code you put in on the thank-you page passes the emailInput variable to the script you put in the thank-you page.