More important, you need to either
[a] copy the FormsPlus JS to your server and point to the URL
or
[b] point to the CDN URL https://cdpn-js.figureone.com/teknkl-formsplus-1.0.5.js
You can't hotlink to the demo the way you're doing now, you'll see this error if you look in your console:
It can't have been working at all if you were trying to load it from cdpn-dl.figureone.com.
Thanks Sanford Whiteman your JS code help me to tracked the hidden value on Known visitor form. It's perfectly work for me. Thanks for your contribution for the community.
Sanford Whiteman, I'm using the solution above and all is working as expected, but we has a recent security audit and they flagged the following:
"They flagged a vulnerability that we have an outdated version of URI.js on the site. URI.js uses v1.18.0 and the newer version URI.js 4.2.2"
Any suggestions on how to update?
*sigh*... "a vulnerability" as if they have any idea whether there's a security concern beyond "the version sounds old."
There's no vulnerability here. The embedded package is just not the very, very latest.
Thanks Sanford, this is why I reached out to get your 2 cents worth, I'll pass this on, I expected it was all good.
Sanford Whiteman - This is awesome! Thank you for this script. It worked perfectly!
One question - is there a way to set default utm_params with this script? For example, in the event that a return visitor comes to a page with Custom HTML set, and there are no utm parameters defined in the URL, we still want to attribute their visit with some type default utm params.
Sure, will update later when I'm by my machine.
OK Craig, you can set default values with the update at
MktoForms2 :: KV HTML w/Auto-Fill and Cascade v1.1.0.
Just add multiple entries for a given field, in priority order from top to bottom.
In the demo, the field Field_With_Fallback is filled first from the query param, then falls back to the constant value if it's still empty. (In fact I think I already had different demo code with this capability, but was too lazy to look for it.)
P.S. A Guaranteed Free Like to all people who can explain 2 reasons why you couldn't add duplicate fields (object keys) to the old code in the same way, in top to bottom order, even if the old code supported an ordered "cascade" of rules.
Very cool! This is great! Your new code is a little different from what I've used (based off of your older example). What would I need to do to add this new 'constant' value to my code? This is currently what I have on my landing page:
var hiddenFieldMap = {
UTM_Campaign__c: {
channel: "query",
selector: "utm_campaign"
},
UTM_Content__c: {
channel: "query",
selector: "utm_content"
},
UTM_Medium__c: {
channel: "query",
selector: "utm_medium"
},
UTM_Source__c: {
channel: "query",
selector: "utm_source"
},
UTM_Term__c: {
channel: "query",
selector: "utm_term"
}
};
/* --- NO NEED TO EDIT BELOW THIS LINE! --- */
var currentCookies = FormsPlus.util.Cookies.get(),
currentQuery = FormsPlus.util.URI.URI().search(true);
var hiddenFields = Object.keys(hiddenFieldMap).reduce(function(acc, field) {
var fieldDescriptor = hiddenFieldMap[field];
switch (fieldDescriptor.channel) {
case "cookie":
acc[field] = currentCookies[fieldDescriptor.selector];
break;
case "query":
acc[field] = currentQuery[fieldDescriptor.selector];
break;
case "constant":
acc[field] = fieldDescriptor.selector;
break;
}
return acc;
}, {});
form.addHiddenFields(hiddenFields);
Can you highlight that JS using the Advanced Editor's syntax highlighter please?