SOLVED

Re: Set Landing Pages to Expire

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

That doesn't look right (or at least complete). Adding/removing a class on a data block doesn't do anything on its own.

 

You want more like

 

 

<div hidden data-datesensitive-show-until="{{my.Expiration Date}}">{{my.Live Content}}</div>
<div hidden data-datesensitive-show-after="{{my.Expiration Date}}">{{my.Expired Content}}</div>

<script>
/* 
  No need to make any changes to this code!
  All config is via data- attributes on 
  conditional elements, as above.
*/
/*
 * Naive date-sensitive element revealer
 * @author Sanford Whiteman
 * @version v1.1.0 2021-05-15
 * @copyright © 2021 Sanford Whiteman
 * @license Hippocratic 2.1: This license must appear with all reproductions of this software.
 *
 */  
(function(){
  const arrayify = getSelection.call.bind([].slice);
    
  const now = new Date();
  
  let axes = ["after","until"];
  let stor = axes.map(function(axis){
    return "[hidden][data-datesensitive-show-" + axis + "]";
  }).join(",");
  
  function makeDate(dateLike){
    dateLike = dateLike.replace(/ /,"T"); // IE requires  'T' as in ISO 8601:2019
    return new Date(dateLike);
  };
  
  arrayify(document.querySelectorAll(stor))
  .map(function(el){
    let conditions = axes.reduce(function(acc,nextAxis){
      acc[nextAxis] = el.getAttribute("data-datesensitive-show-" + nextAxis);
      return acc;
    },{});
    
    return { 
      el : el,
      after : conditions.after ? makeDate(conditions.after) : -Infinity,
      until : conditions.until ? makeDate(conditions.until) : Infinity
    };
   })
  .filter(function(desc){
      return (desc.after <= now) && (now < desc.until);
  })
  .forEach(function(desc){
      desc.el.hidden = false;
  });

})();
</script>

 

 

 

 

 

You do not have to alter the JS at all in this method; it automatically applies to an unlimited number of containers with the data-datesensitive-show attribute.

SandyBarta99
Level 2

Re: Set Landing Pages to Expire

Thanks Sanford,

 

 Not sure why It doesn't work for me.

 

 Copied code straight into an html box in my LP page.

 

 Created the tokenserrorlatereg.PNG

  • Expiration Date- as Date
  • Expired content - as rich text -marketolp/webinar-sara_reg.html
  • Live content - as  rich text      -marketolp/webinar-sara_Lateregistration.html
SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

Would have to see the live page this is on.
SandyBarta99
Level 2

Re: Set Landing Pages to Expire

 

this is my test - Marketo lp

 

lp.PNG

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

I mean a link to the real page, not a screenshot.

Manish_Khemani1
Level 3

Re: Set Landing Pages to Expire

Hi Alec,

 

Marketo Sky (MS) has an 'Expiration' feature that allows you to set an expiration date for Landing pages & Smart campaigns. 

 

In MS go the the program containing the landing page, navigate to assets where you should see an option for Expiration. Now select the asset and there is a button on the far right 'Set expiration' which allows setting an expiration date and time.

 

Try it out 😀.

-Manish

SanfordWhiteman
Level 10 - Community Moderator

Re: Set Landing Pages to Expire

Hi Manish,

 

Marketo Sky (MS) has an 'Expiration' feature that allows you to set an expiration date for Landing pages & Smart campaigns. 

That feature doesn't meet the requirements in this case.

SandyBarta99
Level 2

Re: Set Landing Pages to Expire

thanks Manish, however I need the redirecting to the new landing page as well