The New Year is Coming. Don't be "That Company" – Update Your Date!

Casey_Grimes
Level 10
Level 10

gOSzz2q.jpg

As 2016 is coming to a close, a lot of us in marketing are winding down our schedule for the year: sending out holiday cards, making year-end articles, and building flight plans for 2017's initiatives. However, there's one common thing that can trip you up.

Ever looked at a website and wondered if it is still in operation? Maybe a thing or two looked like they could have been updated – and then you notice the copyright notice the in the footer. "2012. Right, this site must be dead. Let's move along."

Because Marketo lacks any sort of year token out of the box, it's very common for email and landing page designers to take the easy way out: simply add the year as plain text – and then as a new year rolls around, their content is stuck without updated values. But we can do better than that: let's set year dates so they're constantly up to date.

Setting Dates in Emails

Since Marketo only has {{system.date}} (which displays the current system date) and {{system.dateTime}} (a standard datetime stamp), we'll need to do two things: format Marketo's current date to your company's current locale, then set up the token to update in perpetuity (so we're not stuck doing this next December). To do this, we'll utilize folder tokens and Velocity scripting.

Need a refresher on folder tokens? Marketo Tokens: Ins and Outs​ and My.Tokens of Affection: Develop a Token Strategy You'll Love​ cover this topic at length. Remember that with something as generic as a year, you'll likely want to put this in the highest folder available.

You'll also want to check what timezone your Marketo instance is on--for instance, app-aba has its internal clock set to Central Standard Time, which means any datetime calculations it performs are going to be set to CST until you tell it otherwise. Now, for a year that may not matter so much to your company, but if you're sending something time-critical around the holidays or are on a very different timezone than your instance, this may not be ideal.

Once you're in your folder, create an Email Script Token  called  {{my.year}} with the following:

#set($timeZoneObject = $date.getCalendar().getTimeZone())

$date.format("yyyy", $date.getDate(), $date.getLocale(), $timeZoneObject.getTimeZone("America/New_York"))

In this case, I'm setting the timezone to EST, but you should put in whatever timezone is relevant to you. From here, any emails you send with {{my.year}} that are inside this folder will correctly render the right year.

Setting Dates in Landing Pages

Thankfully, when it comes to editing dates for landing pages, the process is much more straightforward. Simply open up your template and swap out your typed date for the following:

<script type="text/javascript">

document.write(new Date().getFullYear());

</script>

Because JavaScript calculates dates on the end user's local machine, this means the year that displays will be whatever that person's current year is--whether that's 2016 or 2017, depending on the date.

8208
21
21 Comments
Robb_Barrett
Marketo Employee

{{my.Year}} = 2017

Set it at the top folder level. Use it in all your LPs and emails.

Grégoire_Miche2
Level 10

Nice reminder Courtney, thx

Robb_Barrett
Marketo Employee

I do love that you included the JS script for pages and the Velocity for emaiLs. It does take out one more thing to remember.

Anonymous
Not applicable

Great title! and so true.

Keith_Nyberg2
Level 9 - Champion Alumni

Thanks for the reminder Courtney Grimes​! Also, providing the JS and Velocity.... VERY helpful!

Joe_Reitz
Level 10 - Champion Alumni

Pretty righteous! Love it.

Anna_Bruning1
Level 4

Thanks so much! This is incredibly helpful. I went through and did the update on our landing page updates, but the landing pages did change to draft mode, as I expected, after I re-approved them the date didn't update. The javascript is working on the template, but not the existing emails. Is that what is supposed to happen or is there a way to have the edit of the template batch update all the landing pages?

Casey_Grimes
Level 10

Hi Anna,

Can you message me? It's hard to know what's going on without specifics to your setup based on what you've said so far. Thanks!

Anonymous
Not applicable

Thanks Courtney - this is going to be such a time-saver moving forward (and a relief to know that we're always using the correct year!)

Anonymous
Not applicable

We use a footer snippet in our emails with our copyright year. I tried creating this token but I can't seem to pull it into a snippet. Is this not possible?