1

I'm working on a landing page that will function as a Subscriber Preferences form for email marketing. It needs to query a particular Data Extension using a given email and populate fields automatically if that email exists, and obviously input the form contents to said Data Extension when submitted.

The form is built in HTML and CSS as the formatting limitations in the content builder were too restrictive, and I have some Javascript to pull the email address from a URL query so I don't need to handle live input there. I don't have much experience with SFMC but as far as I've been able to determine I should be able to embed some Ampscript within the page to handle pre-populating the form, but I'll want to handle form submission using JS and send the data off to a separate page (presumably a code resource?) that will handle updating the DE.

What I'm unsure of is how the syntax is done in a case where I'm writing the HTML directly? Does it need to be in a Script tag of some description?

1 Answer 1

0

Typically, there are two ways to go about this, and they're both reasonably sufficient. AMPScript's web services API can be leveraged to update the data extensions, and so can server-side Javascript and their custom Javascript platform functions.

If you are to go the route of using AMPScript then your form page will also contain the processing code. Since AMPScript runs at page load time the page will need to pass information along in the form post and your ampscript can run the processing functions to update the Data Extension when the form data is present. You'll need to build a web service API object using AMPscript and then insert or update that object with a command.

The other way to go about it is to asynchronously post the data to a separate server-side javascript page and send the response back to the form page for confirmation. You can load js libraries on cloud pages / microsites so you should be able to leverage frameworks like jquery. Your form page then listens for the response and updates appropriately when the success response is passed.

There's plenty of documentation on these methods out there, and here's some initial links to get your wheels turning:

SSJS: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/ssjs_serverSideJavaScript.htm

Ampscript Functions: https://developer.salesforce.com/docs/atlas.en-us.mc-programmatic-content.meta/mc-programmatic-content/functions.htm

4
  • That gives some useful context, thank you. Is there a good way to test/debug either option? It seems like if I have an error somewhere the preview just fails to load and doesn't give details. Commented Oct 10, 2018 at 10:58
  • If you're trying to debug server side javascript you can attempt to debug with node.js and node inspector: npmjs.com/package/node-inspector Commented Oct 10, 2018 at 14:13
  • @mathew nothing for Ampscript, I take it? I wrote <div> %%[ VAR @content SET @content = Lookup('GB_LP_UPDATE_TEST','Mail','Forename','Boris') ]%% %%=@content=%% </div> with the intention it'd be a very simple test page, but I'm pretty sure there's a syntax error in there somewhere. Commented Oct 10, 2018 at 14:25
  • %%=v(@content)=%% Commented Oct 10, 2018 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .