In Form Editor, “null” isn’t the same as NULL (huh?)

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator

You don’t really know Marketo forms until you grok the differences between these 3 form field setups:

2022-07-30-03_58_47-Lab--1511---Test-NULLing-hiddens[1].png

2022-07-30-00_38_43-Lab--1511---Test-NULLing-hiddens[1].png2022-07-30-00_36_33-Lab--1511---Test-NULLing-hiddens-2[1].png

 

Setup #1

2022-07-30-03_58_47-Lab--1511---Test-NULLing-hiddens[1].png

 

This first screenshot is what you get simply by adding a field and flipping its type to Hidden.The field is set to have an empty string as the default value, as you can see in the field details:

2022-07-27-16_53_37-Lab--1511---Test-NULLing-hiddens[1].png

 

However, if you don’t pop up the details, Marketo displays the default value as the string “null”. This can be confusing, as the actual value sent is the empty string “”. (Remember that form fields are always sent as strings, regardless of the back end datatype.)

 

What’s the difference? It’s huge! Sending an empty string does not change the existing value in the Marketo database. Sending the magic string “null” (or capital “NULL” or “Null”, it’s not actually case-sensitive) erases the current value.[1]

 

So at a glance, you might think the hidden field is going to nullify/empty out the server value. But in fact it won't affect the server value at at all.

 

Notably, if you switch the field to use Auto-Fill and then try to switch it back to a constant value, the value can’t be empty!

2022-07-30-00_39_26-Lab--1511---Test-NULLing-hiddens[1].png

 

Unless you remove the field from the form and add it again, the setup that seems like it’ll send “null” but actually sends an empty string “” can’t be reproduced.

 

Setup #2

2022-07-30-00_38_43-Lab--1511---Test-NULLing-hiddens[1].png

 

This next one is a hidden field set to Autofill from a query parameter named utm_medium, with no default value:

2022-07-25-16_07_56-Lab--1511---Test-NULLing-hiddens[1].png

 

Note that in this case, the form does not appear to be sending the value
“null” (which is good, ’cuz it’s not!).

 

Rather, in the main Form Editor view there’s no mention of the default value either way. When you pop up the details, you see the default value is the empty string “”.

 

So the form will not update the server value unless the query parameter is non-empty. If the param is missing or empty[2], an empty string is sent, and the server disregards it.

 

Setup #3

2022-07-30-00_36_33-Lab--1511---Test-NULLing-hiddens-2[1].png

 

This last example is a hidden field that's set to Autofill from the query param utm_medium, falling back to the string “NULL” if the param is missing or empty:

2022-07-25-16_08_11-Lab--1511---Test-NULLing-hiddens[1].png

 

Therefore the form can either fill in the server value or empty it. If the param has a non-empty value, it sends that value. Otherwise, it sends “NULL”, which the server interprets as “erase the current value”.

 

As you might have figured out, this is the setup you typically want for multitouch tracking.

 

You don’t want old UTM values to stick around and get mixed together across form fills. Rather, you want to make sure all UTM fields are updated, as a group, by any form fill.

 

NOTES

[1] Contingent on Block Field Updates allowing the change, of course.

 

[2] The query param utm_medium is present in these two URLs, but has an empty value:

https://pages.example.com?utm_campaign=omg2022&utm_medium=
https://pages.example.com?utm_campaign=omg2022&utm_medium

 

Marketo happens to treat those URLs the same as if the param were completely missing, like in:

https://pages.example.com?utm_campaign=omg2022

 

Yet other apps may draw a distinction. The URLSearchParams spec dictates that missing query params have the implicit value null (not a string “null”, an actual null), while params that are present always have a string value, including an empty string. Tricky!

 

1075
0