I am trying to integrate a form from WordPress landing page to the Marketing cloud to store the data into a data extension.
I have created a cloud page using smart capture to store data into the data extension and it works fine.
When the data is submitted from the external page using POST request, we got some error message that I need to allow cross-origin requests from the external domain, so I found some fix and added this script to the cloud page as below
<script runat=server>
Platform.Load("core","1");
HTTPHeader.SetValue("Access-Control-Allow-Methods","POST");
HTTPHeader.SetValue("Access-Control-Allow-Origin","*");
</script>
After this code, we didn't get that error message, we got the status code 200, but the data is not added to the data extension.
I think the data has never been submitted to the cloud page, my developer asked if there's a receiving function to capture the data from the POST method.
Should I have some code to receive the POST data? I thought the landing page with smart capture page itself will handle the POST request automatically?
I found this AMPscript on the web, not sure if I need to add something like this in the cloud page?
%%[
var @SubscriberKey,@email,@lang
SET @SubscriberKey=RequestParameter('SubscriberKey')
SET @email=RequestParameter('Email')
SET @language=RequestParameter('Language')
UpsertData('Handshake Experiment Cloudpage DE', 1, 'SubscriberKey', @SubscriberKey,'Email', @email, 'Language', @lang)
]%%
Any help here would be really appreciated.
Thanks, Siva