I have spent so many hours just trying to figure out why Velo cannot recognize my form field key/field title to assign a utm parameter to the field… and no I am not misspelling the field key or getting it wrong. The goal here is to take a utm parameter from an ad campaign and place it into a hidden empty field within the Wix v2 Form.
The code below should taking the utm parameter utm_source
from the URL, then locates the form called #djform
which is located on the page, and then it should be calling setFieldValues
to insert the value from the custom parameter utm_source
into the hidden empty field which is called utmsource_1
I keep receiving this exact error:
Argument of type ‘{ utmsource_1: string; }’ is not assignable to parameter of type ‘FormValues’. Object literal may only specify known properties, and ‘utmsource_1’ does not exist in type ‘FormValues’.
import wixLocationFrontend from 'wix-location-frontend';
$w.onReady(function() {
const query = wixLocationFrontend.query;
let utmSource = decodeURIComponent(query.utm_source).toString();
// // Use direct element ID references to set values
if (query.utm_source) {
$w('#djform').setFieldValues({
utmsource_1: utmSource,
});
}
});
For some reason Velo can’t recognize utm_source1 when I’m trying to set that hidden Field Value to a specified utm parameter… the Field Value should be what is essentially an element ID or in this case, a Field Key
Here is the setFieldValues documentation from Velo – https://dev.wix.com/docs/velo/api-reference/$w/wix-forms-v2/set-field-values