Hide custom script from known user?

Anonymous
Not applicable

Hi Marketo community, this is a technical question and I'm not sure if this is allowed to be asked here...

We have a pop-up screen on our landing page to prompt email opt-in, but would like to hide it for known lead.

Was able to figure out the way to hide the form, but can't find a solution to hide the pop-up window which is running from a custom script.

Can anyone point a way to hide the pop-up window or how to identify a known lead in HTML/CSS?

landing URL: Great Lease & Finance Offers from the BC Toyota Dealers | Get Your Toyota - British Columbia

Hope this makes sense.... thank you

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Hi Marketo community, this is a technical question and I'm not sure if this is allowed to be asked here...

(P.S. It certainly is allowed -- stuff that's not in the documentation should be the main focus in the Community! Technical threads can get to a point where the answer/implementation is too complex to be discussed here. But asking the overall question is pretty much always welcome, IMO.)

SanfordWhiteman
Level 10 - Community Moderator

1. Set the form to use Known Visitor HTML ("If Known Visitor, show Custom HTML" in Form Setup).

2. Have the KV HTML contain only a single hidden element. Then you'll know if you're in a Known Visitor context or not, while the form itself will not have anything to display.

<input type="hidden" data-known-visitor="true">

3. On the surrounding page, only load the popup if you know the you're not in a Known Visitor context.

<script>

MktoForms2.whenReady(function(form){

  var formEl = form.getFormElem()[0];

  if ( !formEl.querySelector("[data-known-visitor='true']") ) {

    // here you can load the popup w/the form, since you know the form is visible

  });

});

<script>

Anonymous
Not applicable

Thank you so much, Sanford!

This only worked for the content inside the pop-up, the tint is still over the page 😞

my dev team told me that they cannot control pop-up using known Marketo leads. 

I'm not familiar with script, but I can see that they used jQuery, I might send your solution to them as a reference for further digging.

SanfordWhiteman
Level 10 - Community Moderator

They have to only call the pop-up code *inside* the conditional code I sent -- that's the idea.

Doesn't have to do with jQuery really, it's basic JavaScript logic: only do something (load the pop-up) when a condition is met (there's something to show). If you keep the pop-up logic where it is now, it always runs.