SOLVED

Re: Set Landing Pages to Expire

Go to solution
Anonymous
Not applicable

Set Landing Pages to Expire

Hi everyone,

Is there a way to have a landing page expire after a certain period of time? For example say for a webinar registration page, after the webinar date the page would direct to a "this event has occurred" kind of message? Or would this be a manual process of going back and editing the page after the event has happened?

Looking forward to everyone's thoughts!

Thanks!

Alec

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

Search the Community as this has been answered before. Basically, there is no ​true​ expiry but you can add a standard JS snippet to every page that, together with a {{my.token}} storing the expiration date, can redirect people to a "Thanks... for trying" page/popup/etc.

View solution in original post

18 REPLIES 18
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

Search the Community as this has been answered before. Basically, there is no ​true​ expiry but you can add a standard JS snippet to every page that, together with a {{my.token}} storing the expiration date, can redirect people to a "Thanks... for trying" page/popup/etc.

Robb_Barrett
Marketo Employee

Re: Set Landing Pages to Expire

I'll take Sanford's reply a step further.

In your page template, put in this:

<script type="text/html" id="livepage-html">{{my.Live-Page}}</script>

<script type="text/html" id="expiredpage-html">{{my.Expired-Page}}</script>

Then....

<body>

<div id="body-stuff"></div>

</body>

<script>

if (new Date() > new Date('{{my.expiration-date}}')) {

document.getElementById('body-stuff').innerHTML = document.getElementById('expiredpage-html').innerHTML;

} else {

document.getElementById('body-stuff').innerHTML = document.getElementById('livepage-html').innerHTML;

}

</script>

Then, obviously, in your program put in the following tokens:

expiration-date (type DATE)

Live-Page (type RICH TEXT)

Expired-Page (type RICH TEXT)

Here's an example:

Make an expiration page - JSFiddle

Robb Barrett
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

... but if both HTML variants are going to be pulled into the DOM no matter what, why contain them in <SCRIPT> tags as you would arbitrary non-HTML data? 

It'll be slower to use innerHTML, which causes a reflow and reparse, than to use a hidden parent element and simply move its children under the visible node.

Ayan_Talukder
Level 5

Re: Set Landing Pages to Expire

Really appreciate you sharing the code Robb. Just to clarify for the tokens:

Live-Page = Landing page URL

Expired-Page = Re-direct to page with message

Is that right?

Robb_Barrett
Marketo Employee

Re: Set Landing Pages to Expire

frink.jpg

Here you go:

Hidden Divs - JSFiddle

Robb Barrett
Robb_Barrett
Marketo Employee

Re: Set Landing Pages to Expire

Sanford posts "Do a search" and gets marked correct.  I post a fiddle and get no love.

The system is rigged.

Robb Barrett
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

Sorry man. Joe Reitz​ you can switch the Correct to Robb.  (Though in fairness I posted code, too, if you search. )

Robb_Barrett
Marketo Employee

Re: Set Landing Pages to Expire

I was one "Correct" away from Blogging Rights, but it looks like I got it somehow anyway.

Robb Barrett
SandyBarta99
Level 2

Re: Set Landing Pages to Expire

Hi,

 

I came across your post, but I am struggling. This is my code, but nothing seems to be picked up. I would appreciate any help as I am not a coder. I am using Marketo landing pages. I add this into the live registration landing page

 

 

 

 

<script type="text/html" id="livepage-html">{{my.ZLive-Page}}</script>
<script type="text/html" id="expiredpage-html">{{my.ZExpired-Page}}</script>
Then....
<div id="body-stuff"><br /></div><script>
if (new Date() > new Date('{{my.ZExpiration-Date}}')) {
  document.getElementById('livepage-html').className = "hidden";
  document.getElementById('expiredpage-html').className = "shown";
} else {
  document.getElementById('livepage-html').className = "shown";
  document.getElementById('expiredpage-html').className = "hidden"
}
</script>