SOLVED

How do I dynamically set the current year in an email and landing page?

Go to solution
Highlighted
Anonymous
Not applicable

How do I dynamically set the current year in an email and landing page?

How do I dynamically set the current year in an email and landing page?

Is there Marketo code that can dynamically set the current year as in copyright 2015?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: How do I dynamically set the current year in an email and landing page?

You have to use 2 methods — JavaScript for LPs, Velocity for Emails.

 

On LPs, this snippet will do the trick:

 

<img src="" style="display:none;" onerror="this.outerHTML=new Date().getFullYear();">

 

 

Note: the above is ridiculously far from best practices for authoring JS on the browser side. It's a pretty cringey hack. BUT if you're completely unfamiliar with JS and the DOM, it lets you insert a single HTML element which replaces its own contents at runtime. No prettier ways to accomplish that, AFAIK!

 

For Velocity, I've posted the code a few times before, if you search.

View solution in original post

5 REPLIES 5
Highlighted
Level 10 - Champion Alumni

Re: How do I dynamically set the current year in an email and landing page?

You could add a script to the Template or as Custom HTML.

Another way, which is commonly used, is a Folder token:

{{my.Copyright Year}}

which is changed each year. You embed this token in the Template to work.

Highlighted
Level 1

Re: How do I dynamically set the current year in an email and landing page?

Frank |

Here's a great thread/video that walks you through the process.  Summarily you create a top-most folder (named !Universal)  under Marketing Activities that all your programs reside in, then you set a number token on that top-most folder called copyrightYear with the current year as the number, then you insert the token - {{my.copyrightYear:default=edit me}} - where you want that year and it magically appears when the email is sent out or the landing page is rendered.  That way all you do each year is update that one token and every asset using it reflects the update!

In the html it'll look like something this:  ©{{my.copyrightYear:default=edit me}}

Thread - https://nation.marketo.com/ideas/3110#comment-15198

Video - Architecting a Robust and Scalable Marketo setup (Marketo Summit 2015) - Etumos

R-

Level 1

Re: How do I dynamically set the current year in an email and landing page?

Marketo now supports the token {{system.dateYear}} to populate current year. It is case sensitive. Other similar tokens like {{system.dateMonth}} and {{system.dateDay}} are not supported.

Marketo Certified Expert
Highlighted
Level 1

Re: How do I dynamically set the current year in an email and landing page?

I tried out that token and it says it does not work. Is there a better way to do this on a system level instead of per camaign? 

Highlighted
Level 10 - Community Moderator

Re: How do I dynamically set the current year in an email and landing page?

You have to use 2 methods — JavaScript for LPs, Velocity for Emails.

 

On LPs, this snippet will do the trick:

 

<img src="" style="display:none;" onerror="this.outerHTML=new Date().getFullYear();">

 

 

Note: the above is ridiculously far from best practices for authoring JS on the browser side. It's a pretty cringey hack. BUT if you're completely unfamiliar with JS and the DOM, it lets you insert a single HTML element which replaces its own contents at runtime. No prettier ways to accomplish that, AFAIK!

 

For Velocity, I've posted the code a few times before, if you search.

View solution in original post