Cookie hidden fields don't work if custom html is used for known visitors

Highlighted
Level 2

Cookie hidden fields don't work if custom html is used for known visitors

Hi

I have lot of embedded forms on non-Marketo pages and I would like to make it easier for the visitor to e.g. fill in a webinar forms or ebook download forms.

Idea 1: pre-fill known fields

This doesn't work as the pre-fill unfortunately doesn't work with embedded forms on non-Marketo pages.

Idea 2: "If Known Visitor, Show:" custom html

This does work with embedded forms but the problem is that hidden fields don't take my cookie values.

Anyone other ideas? Transferring the content to Marketo landing pages is a no

33 REPLIES 33
Highlighted

Re: Cookie hidden fields don't work if custom html is used for known visitors

Hi Nick,

Log ideas rather than questions . People can vote and they are reviewed by Product Management.

Idea 1: pre-fill known fields

There are a lot of discussions and ideas already in the community on this. To make it short, there are good data security reasons for not doing this as someone could use your JS code to steal your data.

Idea 2: "If Known Visitor, Show:" custom html

Worth and idea so that we can vote for. Can be worked around with javascript, though.

-Greg

Highlighted
Level 10 - Community Moderator

Re: Cookie hidden fields don't work if custom html is used for known visitors

Nick, you can reenable cookie (and query param) support via the code here: MktoForms2 :: KL HTML w/Auto-Fill

Note the dependency on the FormsPlus::Util (the <script> in the HTML pane).

Once you have that set, the only part you need to change is this little JSON block:

   var hiddenFieldMap = {

      Last_Result__c: {

         channel: "query",

         selector: "utm_results"

      },

      Field_From_Cookie: {

         channel: "cookie",

         selector: "ahoy_visitor"

      },

      Another_Field_From_Constant: {

         channel: "constant",

         selector: "Always use this value."

      }

   };

Hopefully, this is nearly self-explanatory...

  • the top-level properties (Last_Result__c, etc.) are the Marketo form field names
  • you set the channel (this is the term used by the Forms 2.0 API, so I reused it here) to either "query", "cookie", or "constant"
  • set the selector to the specific place to pluck the value from (the name of the cookie or query param to look for, or a static string in the case of "constant")
Highlighted
Level 2

Re: Cookie hidden fields don't work if custom html is used for known visitors

I am actually having this cookie issue with my non-embedded forms. Basically not getting query parameter support when the "If Known Visitor, Show:" custom html is in use.

Will the JSON script above also reenable this data for me? If so where should I place that script?

Thank you so much for your help!

Boone White

Highlighted
Level 10 - Community Moderator

Re: Cookie hidden fields don't work if custom html is used for known visitors

Sure, Boone, you can use the same JS with any Marketo form, whether on a Marketo LP or on another site.

On a Marketo LP, you would include the formsplus-util.js <script>, then the custom JS in another <script>, right before the closing </body> tag.

Highlighted
Level 2

Re: Cookie hidden fields don't work if custom html is used for known visitors

Okay I think I have my mind wrapped around this.

Just to confirm. I am on the right track. Should I make unique properties for each field and related UTM parameter?

See this example for UTM medium:

Screen Shot 2018-03-29 at 1.13.33 PM.png

Thank you so much Sanford, This has been extremely helpful.

Boone

Highlighted
Level 10 - Community Moderator

Re: Cookie hidden fields don't work if custom html is used for known visitors

That's right. The property name in the hiddenFieldMap is the Marketo field name. The property value is an object that describes how/from where the field will be filled.

Highlighted
Level 2

Re: Cookie hidden fields don't work if custom html is used for known visitors

Great, so I will make unique ones for each.

And query would always be the right channel for that yea?

Highlighted
Level 10 - Community Moderator

Re: Cookie hidden fields don't work if custom html is used for known visitors

Right, query = query param.

I have a newer version to publish soon that allows some more channels (like Referrer URL param, which I left off this quick CodePen the other day) and also allows for a "cascade" of channels, i.e. get from such-and-such cookie if exists, otherwise get from such-and-such query param, otherwise look for this other query param... extremely useful. I don't think I'll ever go back to the built-in hidden field AutoFill.

Highlighted
Level 2

Re: Cookie hidden fields don't work if custom html is used for known visitors

Sorry I deleted my prior responses.

For the HTML bit Do I need to paste the whole bit and update all the info to my form/instance details? or do I just need a piece from that code?

Thank you!

Boone