0

In my email I have a CTA that leads to an Cloudpage form embedded on our website. This URL has 'skey' as url parameter, which I need to pass on from the email to the form output. In my cloudpage form I therefore try to fetch this value from the url

set @queryParameterSFID = QueryParameter('skey')

I then try to pass it as a hidden field to my processing page

input type="hidden" name="SFID" id="sfid" value="%%=v(@queryParameterSFID)=%%"

It seems the parameter is not being read from the url, my output is always '@queryParameterSFID'.

My processing page is working fine, when I change the value manually in my console or I hardcode it in my form, I get the correct output. I also can't work with the native cloudpageURL function, I believe, as this is an embedded form, right?

Anyone can help me?

5
  • I need to understand this a bit more: "Cloudpage form embedded on our website" - how are you embedding it? Is it Iframed? "my output is always '@queryParameterSFID'." - this might indicate the ampscript is not parsed properly, so pointing to the form not "running" on cloudpages, but rather just being form fields placed on your website? Commented Nov 12 at 21:45
  • Hi @LukasLunow thanks for your reaction. It is indeed iframed. After some investigation I found another question on the forum where it is stated that it would not be possible to do this exact thing within an iframed cloudpage: link Unless you disagree and there is a way around it?
    – Frederik
    Commented Nov 13 at 8:20
  • I agree - there is a limitation (due to security reasons) what data can be shared between iframed page and the parent page. My advise will be to place the form directly on the page, and use jQuery to populate a hidden field on the form based on query parameter. Commented Nov 13 at 9:13
  • Thank you @LukasLunow Any way I can mark your answer as answer to my question?
    – Frederik
    Commented Nov 13 at 9:47
  • Let me summarize this in an answer Commented Nov 13 at 9:56

1 Answer 1

0

When embedding a CloudPage form within your website using an iframe, accessing URL parameters directly within the CloudPage using AMPscript's QueryParameter function is not feasible due to browser security restrictions that prevent the iframe from reading the parent page's URL parameters.

To pass URL parameters to a hidden field in your embedded form, consider the following approaches:

Direct Form Integration: Instead of using an iframe, integrate the form directly into your webpage. This allows you to utilize client-side scripting, such as JavaScript or jQuery, to read the URL parameters and populate hidden fields accordingly.

PostMessage API: If embedding via iframe is necessary, you could consider implementing the postMessage API to facilitate communication between the parent page and the iframe. It isn't something I have been using myself, but it should theoretically enable the parent page to send the URL parameters to the iframe, which can then process and insert them into the form's hidden fields.

You must log in to answer this question.

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