SOLVED

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

Go to solution
Danielle_Wong
Level 8 - Community Advisor

What are some examples for when a Cookie Value will be empty when a lead fills out a form?

We have leads that are not capturing the cookie value. Is this a normal thing? If so, what are some examples of situations when this would happen?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

I'd be looking for bugs in the code that writes the cookie in the first place.

For example, homegrown code may have a race condition so that on pages with Marketo forms, the cookie may be written either before or after the form is rendered, giving very different results. If your code doesn't understand the Forms 2.0 event model this can easily happen.

View solution in original post

17 REPLIES 17
SanfordWhiteman
Level 10 - Community Moderator

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

What do you mean by "the" cookie value exactly?

Do you mean a Hidden field that's set to AutoFill from a cookie? There's no case where the cookie provably exists where this is known to fail. Do you have more evidence/audit trail about what you're describing?

Danielle_Wong
Level 8 - Community Advisor

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

The issue that sparked this question is: we have a hidden field on some of our forms that is supposed to capture the cookie value from our lead tracking code. However, these are coming in as the hidden field's default value "Null".  I'm not sure how to find an audit trail.

SanfordWhiteman
Level 10 - Community Moderator

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

I'd be looking for bugs in the code that writes the cookie in the first place.

For example, homegrown code may have a race condition so that on pages with Marketo forms, the cookie may be written either before or after the form is rendered, giving very different results. If your code doesn't understand the Forms 2.0 event model this can easily happen.

Danielle_Wong
Level 8 - Community Advisor

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

I don't have much experience in setting up the code that writes the cookie. I've only ever managed the instances after that set up was completed. I'll have to see how to go about it. Thanks so much Sanford for the help with this.

SanfordWhiteman
Level 10 - Community Moderator

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

If you point to the page with the code I can give it a look to see if any bugs immediately jump out.

Danielle_Wong
Level 8 - Community Advisor

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

Awesome, thank you!

Here is the page where our form lives: http://innovate.ieee.org/innovate/contact-us

SanfordWhiteman
Level 10 - Community Moderator

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

Sure enough, the developer doesn't understand how Marketo Forms work.

This code cannot work predictably:

$(document).ready(function() {

  var a = "ieee.org";

  var c = document.referrer;

  var b = "LT";

  var d = getUrlParameter(b);

  if (typeof d != "undefined" && null != d && d != "") {

    $.cookie("LT", d, { expires: 730, path: "/", domain: a });

  }

});

When you wait for jQuery's ready (this is equivalent to the native event DOMContentLoaded) there's no guarantee that it will run before the Marketo form is finished drawing.

Marketo loads form descriptors (that's the technical name for the setup you manage in Form Editor) and injects HTML elements asynchronously. It doesn't wait for ready before beginning this process.

Therefore, depending on network conditions, caching, and other remote assets loaded by the page, the cookie code might run either before or after the form is ready for use. If it runs after, there are no cookies for the form to see.

This code should run synchronously, i.e. not wrapped in ready.

Danielle_Wong
Level 8 - Community Advisor

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

I am super appreciative of the time and effort you put into this! This is super helpful and I will work to get this fixed ASAP.

Danielle_Wong
Level 8 - Community Advisor

Re: What are some examples for when a Cookie Value will be empty when a lead fills out a form?

Hi Sanford,

Not sure if you have any insight on this.

I noticed this form is not pulling in the LT value from the url. I made sure to clear my cache and when I test it, it doesn't pull in the LT value: Testing1. Any idea why this is happening?

My field is set up like this:

lt.jpg

Thank you

Danielle