The New Year is Coming. Don't be "That Company" – Update Your Date! | Community
Skip to main content
Casey_Grimes2
New Participant
December 27, 2016

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

  • December 27, 2016
  • 21 replies
  • 11684 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

21 replies

Anna_Blanchet1
New Participant
January 3, 2023

Thank you @darshil_shah1! I appreciate the visual. 

Darshil_Shah1
Community Manager
December 22, 2022

Here's the visual aid on where/how JS could be added to the snippet - 

 

Click HTML > Add JS (within <script> </script> tag) > Hit Apply

SanfordWhiteman
New Participant
December 21, 2022

Well, Snippets have an HTML editor. So insert it the same way you’d insert it into an HTML section on an LP.

Anna_Blanchet1
New Participant
December 21, 2022

Hi @sanfordwhiteman - I was looking to gain clarity on the approach, not just confirmation that it is possible. How would you approach inserting the JS into a snippet? 

SanfordWhiteman
New Participant
December 21, 2022

@anna_blanchet1 sure, why not?

 

Anna_Blanchet1
New Participant
December 21, 2022

@casey_grimes2 Tis the season to update copyright years! Question - our landing pages use snippets for disclaimer text. Is there a way to insert the Javascript into a snippet?

Amanda_Thomas6
New Participant
January 15, 2018

Awesome! Thanks, Sandford!

SanfordWhiteman
New Participant
January 10, 2018

If Velocity tokens are not working in Web View, open a Support case. This is broken on some Mkto instances, but the correct behavior is for VTL to display as it does in email content.

Amanda_Thomas6
New Participant
January 10, 2018

We're trying to do this at the template level, so we enter the code which populates perfectly fine with the email. However, when you view email in browser all you see is the code. We'd love to have a system token for the year only (vs the full date).

November 20, 2017

Thanks, Courtney. My issue is that the token is in Marketing Activities but the snippet is in the Design Studio. The snippet is not recognizing the my.token. I could've sworn I read in the community that someone had pulled in a custom token into a snippet but I can't figure out how.