SOLVED

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

Go to solution
Anonymous
Not applicable

Understanding form fill UTMs - URL Parameters vs Cookie Value

Trying to get a better understanding of how our UTM fields are being populated.

To my understanding, on our landing pages we have scripts that append the UTM's on the Cookies.

So when I create the hidden value on the form, I can select Get Value from "Cookie Value".

There are times where the value is blank and will grab the default value.

But we also provide UTM tags using URL Parameters to our advertising agency for display ads.

But, form fills using those links, are coming with blank UTM values.

Is selecting get value from "URL Parameter" vs "Cookie Value" on a form exclusive option?

And is there a way to tell the from to get it from the cookie first and if value is blank get it from the URL? or vis versa?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

I'm looking at the code and there are actually two problems.

One is that the person who wrote it didn't use the Forms 2.0 API correctly, so the code is basically guessing about whether the form is loaded before it copies current the URL parameters into form fields. That is, if the form is not yet ready, there's nowhere for the values to go, so they are just thrown away.  (You may not even realize that there's code intended to do this, since it doesn't work reliably.)

It also seems that the code to copy URL params to individual cookies isn't present on the page.  So it's not a question of load order but of whether the script is running at all.

I think you should have a dev review the code for both placement and proper operation.

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

(You should post in the Products space going forward -- that's the main support question-and-answer board.)

If you're always saving the current UTM parameters to cookies, you just need to make sure that helper script runs and completes before the form loads.  Sounds like you're loading the form before your script copies query params --> cookies, so at the time the form loads there aren't any cookies to find. Does that make sense?  If you send me an actual URL with a form I can tell you what's up with the order.

Anonymous
Not applicable

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

Hi Sanford Whiteman,

​What you said about the script completing before the form loads makes sense.

I did not create the page and no longer have access to who created it to ask, but know there are random scripts placed in difference areas on the page.

​Here is the link that I am unable to get the hidden UTM field to grab from either Cookie or URL - Gartner Report: Magic Quadrant for Enterprise Int...

Are you able to tell me if script completing before form loads is the case? and if so is it an easy fix?

Thanks

Bryant

SanfordWhiteman
Level 10 - Community Moderator

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

I'm looking at the code and there are actually two problems.

One is that the person who wrote it didn't use the Forms 2.0 API correctly, so the code is basically guessing about whether the form is loaded before it copies current the URL parameters into form fields. That is, if the form is not yet ready, there's nowhere for the values to go, so they are just thrown away.  (You may not even realize that there's code intended to do this, since it doesn't work reliably.)

It also seems that the code to copy URL params to individual cookies isn't present on the page.  So it's not a question of load order but of whether the script is running at all.

I think you should have a dev review the code for both placement and proper operation.

Anonymous
Not applicable

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

Thanks Sanford Whiteman​,

Appreciate you taking a look.

Was afraid of that would be the issue, but will reach out to a developer to take a look.

Thanks again.

Bryant

SanfordWhiteman
Level 10 - Community Moderator

Re: Understanding form fill UTMs - URL Parameters vs Cookie Value

OK, let me know if you have any more questions.  Your developer should be attentive to the Forms 2.0 MktoForms2::whenReady event. Until this event has fired, you can't populate fields in the form (as I mentioned, there is code on the page that tries to push current URL params into the form directly).  Also, s/he should use the Forms 2.0 form#setValues method to populate fields.  Using generic methods to set values will silently fail in some cases.

But more efficient, as I wrote earlier, is not trying to directly fill any fields.  Instead, just be sure any interesting query params are copied into cookies before you call loadForm(). Then the form's hidden fields can always Autofill from cookies. Doesn't matter of those cookies were from a previous page view or the current view, as long as they're set before the form loads.