Skip to main content
Level 2
6月 11, 2022 3:56 午後 UTC
解決済み

Can I dynamically control a global form field’s visibility based on the page URL the form is hosted on?

I am trying to dynamically control a field’s visibility on a global form using a hidden field that would reference the hosted page URL. Would I be able to use the visibility rules feature. Configuring a hidden field to pull and the URL of the current page?

このトピックへの返信は締め切られました。
SanfordWhiteman
User Group Leader
6月 11, 2022 6:00 午後 UTC

The Visibility Rules part will work fine. But you’ll have to set the Hidden field via JS as there’s no builtin way to fill from the entire current URL. Assuming your field is called Last Marketo Form URL:

MktoForms2.whenReady(function(mktoForm){ mktoForm.setValues({ LastMarketoFormURL : document.location.href }); });

 

3 の返信

SanfordWhiteman
User Group Leader
User Group Leader
6月 11, 2022 6:00 午後 UTC

The Visibility Rules part will work fine. But you’ll have to set the Hidden field via JS as there’s no builtin way to fill from the entire current URL. Assuming your field is called Last Marketo Form URL:

MktoForms2.whenReady(function(mktoForm){ mktoForm.setValues({ LastMarketoFormURL : document.location.href }); });

 

翻訳
Goldengaines作成者
Level 2
6月 13, 2022 2:30 午後 UTC

@sanfordwhiteman  - Thank you for the reply and proposed solution. Just to be clear this snippet of JS should be on the landing page the form is on,  correct?

翻訳
SanfordWhiteman
User Group Leader
User Group Leader
6月 13, 2022 6:24 午後 UTC

. Just to be clear this snippet of JS should be on the landing page the form is on,  correct?

Yes, if it’s a Marketo LP, put the code just before the closing <body> tag.

翻訳