Check cookie to see if user has filled a form before JS

Anonymous
Not applicable

Check cookie to see if user has filled a form before JS

Hi everyone,

I'm currently combining Forms 2.0 with some JS inside an onSuccess callback, that will append a download link once the form has been submitted (I've achieved this okay!)

What I'm looking to do is check for a marketo cookie when a user visits the form to see if they've filled out the form in the past:

Does marketo set a cookie that contains this information once a form is submitted?
How would I access that if so?

Regards
Tags (1)
3 REPLIES 3
Kenny_Elkington
Marketo Employee

Re: Check cookie to see if user has filled a form before JS

Hi Stan,

We do not set a cookie in the browser automatically if a lead has filled out a form, but it should be quite simple to implement one yourself.  You can also use getLeadActivity from our SOAP to check for Form Fillouts on a records, but that'll require some servers-side work.  Setting the cookie in the browser is probably simpler.
Anonymous
Not applicable

Re: Check cookie to see if user has filled a form before JS

You can check if the Marketo cookie exists, but this would not indicate if they have a filled out a certain form. This StackOverflow questions shows how to check for a Marketo cookie with jQuery:

http://stackoverflow.com/questions/6362688/jquery-check-if-cookie-exists-if-not-create-it

A
s Kenny described, getLeadActivty is the best way to check for form fill activity. You can query this API with the value of the user's cookie. So it possible to do this in real-time when a visitor is on your website. 
Anonymous
Not applicable

Re: Check cookie to see if user has filled a form before JS

A second approach, which would be easier, is to put your own cookie on a user's browser when the form is filled out. Then check if the cookie exists before loading a form.