SOLVED

Re: Way to hide form on a landing page after a specified date?

Go to solution
Nicole_Burns2
Level 1

Way to hide form on a landing page after a specified date?

Hi there!

Curious if there is a way to hide a form that appears on a landing after a certain date? Use case being, the event is over and I want to avoid any future submissions. I do not want to have to go in manually to update the landing page but rather use some kind of scripting to hide/remove the form after the last date of the event.

I realize there is an option to display custom text instead of the form if the visitor is known but I am trying to deter new submissions. I also see there are form settings at the landing page level but it is only for the followup page after submission.

I have seen this article about what to do with post-event landing pages, but I don't necessarily want to push visitors to any on-demand content or current content. I have also seen articles (like this one that Sanford answered) about conditionally showing the submit button, which might work, but I can't quite figure out what condition I would use and how it could be influenced by the date.

I am somewhat new to Marketo so I may be overlooking something really obvious! Sorry if I am!

Any suggestions would be wonderful! Thanks! =D

1 ACCEPTED SOLUTION

Accepted Solutions
Jay_Jiang
Level 10

Re: Way to hide form on a landing page after a specified date?

If you have the event date in a program token already...

pastedImage_0.png

You can add a script like this:

<script>

MktoForms2.whenReady(function(form) {

var eventDate = new Date("{{my.eventdate}}"),

today = new Date(),

formEl = form.getFormElem()[0];

eventDate.setHours(0,0,0,0);

today.setHours(0,0,0,0);

if(eventDate<today){formEl.innerHTML = "This event is over"}

});

</script>

N.B. this ignores timezones and assumes the person visiting the landing page and the event are all in the same timezone.

View solution in original post

7 REPLIES 7
Jay_Jiang
Level 10

Re: Way to hide form on a landing page after a specified date?

If you have the event date in a program token already...

pastedImage_0.png

You can add a script like this:

<script>

MktoForms2.whenReady(function(form) {

var eventDate = new Date("{{my.eventdate}}"),

today = new Date(),

formEl = form.getFormElem()[0];

eventDate.setHours(0,0,0,0);

today.setHours(0,0,0,0);

if(eventDate<today){formEl.innerHTML = "This event is over"}

});

</script>

N.B. this ignores timezones and assumes the person visiting the landing page and the event are all in the same timezone.

Nicole_Burns2
Level 1

Re: Way to hide form on a landing page after a specified date?

Thank you so much Jay! This is perfect!

I have tried adding this script to the landing page a few ways and it isn't working but could be a setting on the landing page itself or something I am doing wrong. I'll keep trying.

Thanks again!

Jay_Jiang
Level 10

Re: Way to hide form on a landing page after a specified date?

One thing I left out is that the script needs to be added after the form. Having the script before the form will not work.

pastedImage_0.png

Nicole_Burns2
Level 1

Re: Way to hide form on a landing page after a specified date?

Thanks for this! Unfortunately, I do not have that element available to me but I will use this article from Gregoire to figure out a way to add it, obviously keeping in mind the placement below the form.

Thanks again for all the help!

Nicole_Burns2
Level 1

Re: Way to hide form on a landing page after a specified date?

UPDATE: WOO HOO!! I was able to simply add as an HTML in a basic text element and it worked like a charm! Thank you again, Jay!

Chris_Willis1
Level 8 - Champion

Re: Way to hide form on a landing page after a specified date?

@jay - this is great!  Can you add HTML elements in this replacement text (such as an anchor tag to direct to a replay page)?

SanfordWhiteman
Level 10 - Community Moderator

Re: Way to hide form on a landing page after a specified date?

innerHTML treats strings as HTML always, so yes.