SOLVED

Re: Form "Not You?" functionality

Go to solution
Anonymous
Not applicable
Do any of you use "Not You?" buttons on forms (along side the Submit button)?

If so, how do you do this functionality?
Thanks!
Tags (1)
1 ACCEPTED SOLUTION
Rafael_Santoni1
Level 5
This is how we implemented it.

We have a link in all our Marketo pages that asks the visitor to "click here" if the information on the form is not theirs to re-set the information. Once the person clicks on that, a javascript function we created clears the cookie and re-loads the page.

In addition to that, we check for a URL parameter (userID=guest). If any of our pages are called with that URL parameter present, we also clear the Marketo prefill and all the fields prior to rendering the page. We do that with a short JavaScript function. This allows us to link to any of our Marketo lead capture pages forcing not pre-filling the forms even for known leads if we wanted to.

Summary:
  1. Create a function that would clear the values, cookie, etc.
  2. Place link on your template to call the function to clear and reload the page.
Simple, non-intrusive, and easy to deploy and maintain.

If you wanted to apply the same functionality to the reset button on the form, you can use jQuery to "listen" to a click on the button and fire the same function or have it call the same page with the "magic" URL parameter.

Good luck!

Rafael

View solution in original post

25 REPLIES 25
Courtney_McAra4
Level 4

Small plug for LaunchPoint Partner Marketera who can help with things like this - aka a Resource Center

Marketing Design: Web, Email, Social, & Print – Marketo LaunchPoint

Anonymous
Not applicable

Unfortunately this doesn't seem to work for me with Marketo's new guided templates!

Has anyone got this working or have an alternative with the guided templates?

SanfordWhiteman
Level 10 - Community Moderator

Matthew, the most accurate way to do this (on any page, including a GLP) is illustrated in the script at the bottom of this page: http://pages.vaneck.com/Lab-GLP-Guest-Form.html

As noted above, you should use the Forms 2.0 API. The API has a whenReady event that tells you when the form is ready for use.  Any other attempt to time when the form is ready (and therefore ready to be reset) relies on luck.

Rafael_Santoni1
Level 5

Matthew,

I am sure it is possible even with those templates because the solution is not dependent on the template used. The Marketo cookie is "_mkto_trk" no matter what template you use and the prefilled values leverage the mktoPreFillFields array always. As long as you can destroy the cookie, it should work and clear the prefill values, you should be ok. Try putting the code below on one of your pages and visit the URL appending "?userId=guest" right after the page address. Make sure to replace the part that says "insert_your_domain_here" with your Marketo page URL domain name.

<script>

$jQuery(document).ready(function(){

if(Mkto.getUrlParam("userId") == "guest"){

         $jQuery("#_mkt_trk").val('');

         mktoPreFillFields = {};

         $jQuery(".lpeRegForm")[0].reset();

         document.cookie = '_mkto_trk=NULL; expires=-1; path=/; domain=.insert_your_domain_here.com';

     }  

});

</script>

By the way, there might be some tweaks needed for this code to work depending on the form you are using on the page.

If you have any problems implementing it, feel free to drop me a line at rafael.santoni@citrix.com

Good luck!

Rafael

SanfordWhiteman
Level 10 - Community Moderator

Rafael, really shouldn't use NULL here because misleadingly implies it has a special value, but it's just a literal four-letter string "NULL" in the cookie context.  For example, if I do document.cookie='abc123=NULL ... ' I'll then have a cookie named abc123 with value "NULL".  Instead, when deleting a cookie, use an empty value to signify your intent to delete it: document.cookie='_mkto_trk=; ... ';

Also, Forms 2.0 doesn't have the #_mkt_trk field, so you don't need to clear its value, though I suppose it's harmless to use it.

Perhaps more important than the above, your code has a race condition if you try to use it with embedded forms (including when the external embed code is used on Marketo-hosted LPs).  It'll sometimes work and sometimes not.  You should use the Marketo Forms 2.0 API (the whenReady event) to ensure that the form actually exists in the DOM at the point you try to reset it.  Don't try to guess when the form is in the page, let the form itself tell you when it is ready to be filled/reset/modified.

Anonymous
Not applicable

Thanks for the help and responses.

Still having some difficulty...

Here's what I got;

http://funds.clime.com.au/Clime-Outlook-for-2016.html

<script type="text/javascript">

jQuery(document).ready(function($){

    function resetMktoForm() {

        $("#_mkt_trk").val('');

        mktoPreFillFields = {};

        $(".mktoForm")[0].trigger("reset");

        document.cookie = '_mkto_trk=; expires=-1; path=/; domain=.clime.com.au';

    }

   

    if(window.location.search.indexOf("userID=guest") > -1){

        resetMktoForm();

    }

});

</script>

I'm no coder but after looking at this, I actually think the reset function is no longer defined in the version of jQuery I'm using.

It is causing this error:

TypeError: $(...)[0].reset is not a function

Old Jquery

I used to use in old land pages before Guided Templates

https://app.marketo.com/js/public/jquery-latest.min.js

New Jquery

Required for Guided Landing Pages because of Bootstrap

templates.marketo.net/template2/js/jquery-1.11.2.min.js

I have tried various things to no avail.

SanfordWhiteman
Level 10 - Community Moderator

Use the code from the link in my post. 

My code never relies on jQuery (because I know native JS and because jQuery is unnecessary for something so minor).

Anonymous
Not applicable
Thanks for the code it was very usefull but as mentioned above Marketo should integrate this as an option in the form builder. 

- one option should be to create a link above the form (f.e. Not you? Click to clear form)
- second option should be a button a the bottom of the form (F.e Clear Form)

Both options should be available the first one if the form is pre-populated with details of someone else
Second option I would use in case when it is a longer form and the user just wants to clear it at the end. 
Anonymous
Not applicable
Here is the jQuery that we will be implementing on our forms. It has been tested on Forms 2.0 and it resets the fields if the "Not You" link is clicked or if the URL has "user=guest" as a parameter.

Note: I did change the previous "userID" to "user" to shorten it.

jQuery(document).ready(function($){

    function resetMktoForm() {
        $("#_mkt_trk").val('');
        mktoPreFillFields = {};
        $(".mktoForm")[0].reset();
        document.cookie = '_mkto_trk=NULL; expires=-1; path=/; domain=.planview.com';
    }
    
    if(window.location.search.indexOf("user=guest") > -1){
        resetMktoForm();
    }
    
    // If Clear is clicked remove Marketo cookies, prefill, etc.
    $('html').on('click', '.mktFrmReset', function (event) {
        event.preventDefault();
        resetMktoForm();
    });

});

Also, here is our "Not You" link code we have inserted as Rich Text in our form:

<a href="#" class="mktFrmReset">Not You? Reset this form</a>

We're still working on getting this to work with Progressive Profiling. Currently if Progressive Profiling is enabled and the "Not You" link is clicked, it does not completely refresh the form to show the Progressive Profiling fields that are not visible. It only resets the visible fields.

My developer is working to make this work with Progressive Profiling, but I wanted to share what we have now. Enjoy!

Allison
Anonymous
Not applicable
Thank you, Rafael, for the information and code! I'll be starting implementation and testing of this very soon on my company's Marketo registration pages.

Hopefully this will be a built-in feature in a future release of the forms.

Allison
Rafael_Santoni1
Level 5
The code I sampled here can be used in a regular text link, the submit button or even by loading the page with url parameters. If you have access to a JavaScript developer, it should be clear how to implement it. On my pages, I leverage it whenver the page is loaded with the url parameter userId=guest, so I simply use a relative text link on the page that links to the same page itself, including the url parameter.

i.e. If the form pre-populated below is not you, 
   < a id="mktoGuest" href="?userId=guest">click here</a >

But you could also invoke it by calling the function from a regular text link.

The reset button does not necessarily clear the cookie values, just the field values but the person might still be recognized, so I ensure to remove all traces by doing both things at the same time.

I hope that helps clarify it.

Rafael
Anonymous
Not applicable
Hopefully someone is still subscribed to this thread...

If we wanted to make the clear happen via clicking on some text like "Not You? Click here..." how would we make that happen?

As far as I can tell the javascript above is only for the "Clear" button that shows below the forms.

My unsubscribe form has a bunch of text breaks and things, so having the clear button be all the way at the bottom doesn't serve my needs. I want to have text next to the email field that allows them to clear it there.

Thanks!
Anonymous
Not applicable
[deleted]
Anonymous
Not applicable
This is awesome! We are having issues in this area and this is likely one good way to help alleviate our problems too. Thanks!!
Rafael_Santoni1
Level 5
Scratch my last comment, I just realized that you were working on 2.0 forms. Good to know. The other thing that could be done is to reset any form regardless of which class they are using. Since in most cases, there would be only one form, that should take care of both cases.

i.e.
$jQ("form")...
Rafael_Santoni1
Level 5
Hey Adam, I am curious about one thing. That would not work in my case because my forms never make use of that class. Mine consistently use lpeRegForm instead. Are you using the original form editor or version 2?
Anonymous
Not applicable
Thanks again.  

I was just working on implementing this today and after playing around with a 2.0 form, I was able to get this working there as well.  The form name referenced in the reset should be ".mktoForm" instead of ".lpeRegForm".  

So this:
$jQ(".lpeRegForm")[0].reset();

Should become this:

$jQ(".mktoForm")[0].reset();

And everything should work.  

Thanks!
Adam
Rafael_Santoni1
Level 5
No problem Adam. Any time.

BTW... this is how I do it with the URL parameter (if the URL has userId=guest):

	if(Mkto.getUrlParam("userId") == "guest"){
	        $jQ("#_mkt_trk").val('');
	        mktoPreFillFields = {};
	        $jQ(".lpeRegForm")[0].reset();
	        document.cookie = '_mkto_trk=NULL; expires=-1; path=/; domain=.citrix.com';
	    }



Anonymous
Not applicable
Thanks much Rafael!
Rafael_Santoni1
Level 5
This is what I do to make the "Clear" button reset the visitor properly

// Use jQuery via $jQ(...)
var $jQ = jQuery.noConflict();
 
$jQ(document).ready(function(){
 
// If Clear is clicked remove Marketo cookies, prefill, etc.
$jQ( "#mktFrmReset" ).click(function() {
 
$jQ("#_mkt_trk").val('');
        mktoPreFillFields = {};
        $jQ(".lpeRegForm")[0].reset();
        document.cookie = '_mkto_trk=NULL; expires=-1; path=/; domain=.citrix.com';
 
});
 
});

I have not tested this on pages with forms from the Forms 2.0 editor, only on pages with the original forms editor.