0

I've built a cloudpage with the Content Builder and need to redirect the user to a URL on submission of a smart capture form, this is all working fine, but I need to pass the email address captured in the form through to the exit page as part of the query string.

I have tried doing this via JavaScript and modifying the URL in the SC init code, but this doesn't seem to work, as it results in a undefined URL.

I'm wondering if there is a way to do this purely in Salesforce without messing with the generated smart capture code.

var email;
function getEmail() {
    var email = document.getElementById('EmailAddress').value;
}
var url = "https://pub.s7.exacttarget.com/xxxxxxx?emailaddress=".email;

window.ScForm.init({"gearID":"l2l88a3ru0a","smartCaptureFormID":0,"sourceKey":"EEE4BBB7-11B0-453B-90F1-827653B5C7D1","source":"dataExtension","triggeredSend":"","confirmationMessage":"Thank you for your submission.","buttonText":"Submit","formStyling":{"background-color":"#f3f3f3","width":"80%","padding-top":"20px","padding-right":"20px","padding-bottom":"50px","padding-left":"20px","margin-top":"0","margin-right":"auto","margin-bottom":"0","margin-left":"auto","border-color":"transparent","border-width":"0px","border-style":"solid","border-top":false,"border-right":false,"border-bottom":false,"border-left":false},"fieldStyling":{"width":"100%","-moz-box-shadow":"inset 1px 1px 4px #CCCCCC","-webkit-box-shadow":"inset 1px 1px 4px #CCCCCC","box-shadow":"inset 1px 1px 4px #CCCCCC","border":"1px solid #CCCCCC","color":"#222222","display":"inline-block","font-size":"12px","line-height":"1.3","margin-bottom":"9px","padding":"7px","height":"35px !important"},"buttonStyling":{"background-color":"#009DDC","border-color":"#009DDC","border-radius":"3px","border-style":"solid","-webkit-border-radius":"3px","-moz-border-radius":"3px","color":"#FFFFFF","font-family":"Arial, Helvetica, sans-serif","font-size":"16px","line-height":"normal","padding":"10px"},"onSubmitShouldGotoUrl":true,"onSubmitGotoUrlType":2,"onSubmitGotoUrl": url});
 };

The form onsubmit has been changed to

onsubmit="getEmail()"
  • Can you show the code that you are trying to write for passing URL parameters. This should be possible through javascript – RedDevil Jun 10 '17 at 10:12
2

You can do something like this

function getEmail() {
    var email = document.getElementById('EmailAddress'); //fetch the email address
}
var url = "https://pub.s7.exacttarget.com/xxxxxxx?emailaddress=";
window.location.href = url.concat(email); // will redirect to the url

window.ScForm.init({"gearID":"l2l88a3ru0a","smartCaptureFormID":0,"sourceKey":"EEE4BBB7-11B0-453B-90F1-827653B5C7D1","source":"dataExtension","triggeredSend":"","confirmationMessage":"Thank you for your submission.","buttonText":"Submit","formStyling":{"background-color":"#f3f3f3","width":"80%","padding-top":"20px","padding-right":"20px","padding-bottom":"50px","padding-left":"20px","margin-top":"0","margin-right":"auto","margin-bottom":"0","margin-left":"auto","border-color":"transparent","border-width":"0px","border-style":"solid","border-top":false,"border-right":false,"border-bottom":false,"border-left":false},"fieldStyling":{"width":"100%","-moz-box-shadow":"inset 1px 1px 4px #CCCCCC","-webkit-box-shadow":"inset 1px 1px 4px #CCCCCC","box-shadow":"inset 1px 1px 4px #CCCCCC","border":"1px solid #CCCCCC","color":"#222222","display":"inline-block","font-size":"12px","line-height":"1.3","margin-bottom":"9px","padding":"7px","height":"35px !important"},"buttonStyling":{"background-color":"#009DDC","border-color":"#009DDC","border-radius":"3px","border-style":"solid","-webkit-border-radius":"3px","-moz-border-radius":"3px","color":"#FFFFFF","font-family":"Arial, Helvetica, sans-serif","font-size":"16px","line-height":"normal","padding":"10px"},"onSubmitShouldGotoUrl":true,"onSubmitGotoUrlType":2,"onSubmitGotoUrl": url});
 };

call the function in the form onsubmit event

1

FYI, Danger Will Robinson. This answer LOOKS like it works but iphone submissions actually don't get added into the data extension, for whatever reason. The redirect works on them though.

  • Thanks, in the end I had to ditch the entire code and stick to standard processing of the post data. Content builder seems to be a bit flaky when it comes to doing anything outside the norm – terrorfall Oct 22 '17 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.