4 Replies Latest reply on Aug 1, 2018 10:11 AM by Sanford Whiteman

    Hide custom script from known user?

    Carolyn Jia

      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

        • Re: Hide custom script from known user?
          Sanford Whiteman

          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>
          
          • Re: Hide custom script from known user?
            Sanford Whiteman

            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.)