AnsweredAssumed Answered

Change landing page based on time zone with Javascript

Question asked by Kassia Wilhelm on Sep 2, 2014
Latest reply on Nov 2, 2015 by Kassia Wilhelm
I am setting up a webinar that I want to show in the user's time zone - everyone seeing the landing page is already in Marketo and has a Time Zone field populated for them. I wrote an email script token to change the time zone in emails, now I want the landing page to also change the time zone displayed but there is nothing like an email script token for landing pages. I wrote some javascript to try to populate a <span> that I put an ID on based on the lead's Time Zone field. However, the Javascript isn't working.

I think what's breaking is the way I'm referencing the lead field - how do you reference a specific lead field in Javascript to populate on a landing page?

I've tried a handful of things, this is where I left off with the HTML element I put on the landing page:

     <script language="Javascript" src="/js/public/jquery-latest.min.js" type="text/javascript"></script>
     <script src="/js/public/jQueryString-2.0.2-Min.js" type="text/javascript" ></script>
      
      
     <script type="text/javascript">
      
     window.onload = function () {
      
     var userTimeZone = "[user:TimeZone]";
     var tz = "10:00 AM - 10:45 AM PDT";
      
     if ("userTimeZone" == "Pacific/Tongatapu") {
     tz = "6:00 AM - 6:45 AM TOT";
     } else if ("userTimeZone" == "US/Samoa") {
     tz = "6:00 AM - 6:45 AM SST";
     } else if ("userTimeZone" == "US/Hawaii") {
     tz = "7:00 AM - 7:45 AM HAST";
     } else if ("userTimeZone" == "US/Aleutian") {
     tz = "8:00 AM - 8:45 AM HADT";
     } else if ("userTimeZone" == "US/Alaska") {
     tz = "9:00 AM - 9:45 AM AKDT";
     } else if ("userTimeZone" == "US/Pacific") {
     tz = "10:00 AM - 10:45 AM PDT";
     } else if ("userTimeZone" == "US/Arizona") {
     tz = "10:00 AM - 10:45 AM MST";
     } else if ("userTimeZone" == "US/Central") {
     tz = "12:00 PM - 12:45 PM CDT";
     } else if ("userTimeZone" == "US/Mountain") {
     tz = "11:00 AM - 11:45 AM MDT";
     } else if ("userTimeZone" == "Canada/Saskatchewan") {
     tz = "11:00 AM - 11:45 AM CST";
     } else if ("userTimeZone" == "America/Guatemala") {
     tz = "11:00 AM - 11:45 AM CST";
     } else if ("userTimeZone" == "America/Bogota") {
     tz = "12:00 PM - 12:45 PM COT";
     } else if ("userTimeZone" == "America/Mexico_City") {
     tz = "12:00 PM - 12:45 PM CDT";
     } else if ("userTimeZone" == "America/Caracas") {
     tz = "12:30 PM - 1:15 PM VET";
     } else if ("userTimeZone" == "US/Eastern") {
     tz = "1:00 PM - 1:45 PM EDT";
     } else if ("userTimeZone" == "America/Santiago") {
     tz = "1:00 PM - 1:45 PM CLT";
     } else if ("userTimeZone" == "America/La_Paz") {
     tz = "1:00 PM - 1:45 PM BOT";
     } else if ("userTimeZone" == "Brazil/East") {
     tz = "2:00 PM - 2:45 PM BRT";
     } else if ("userTimeZone" == "America/Halifax") {
     tz = "2:00 PM - 2:45 PM ADT";
     } else if ("userTimeZone" == "America/Buenos_Aires") {
     tz = "2:00 PM - 2:45 PM ART";
     } else if ("userTimeZone" == "America/Montevideo") {
     tz = "2:00 PM - 2:45 PM UYT";
     } else if ("userTimeZone" == "America/St_Johns") {
     tz = "2:30 PM - 3:15 PM NDT";
     } else if ("userTimeZone" == "Atlantic/South_Georgia") {
     tz = "3:00 PM - 3:45 PM GST";
     } else if ("userTimeZone" == "America/Godthab") {
     tz = "3:00 PM - 3:45 PM WGST";
     } else if ("userTimeZone" == "Atlantic/Cape_Verde") {
     tz = "4:00 PM - 4:45 PM CVT";
     } else if ("userTimeZone" == "Greenwich") {
     tz = "5:00 PM - 5:45 PM GMT";
     } else if ("userTimeZone" == "Atlantic/Azores") {
     tz = "5:00 PM - 5:45 PM AZOST";
     } else if ("userTimeZone" == "Europe/Lisbon") {
     tz = "6:00 PM - 6:45 PM WEST";
     } else {
     tz = "10:00 AM - 10:45 AM PDT - default result";
     }
     document.getElementById("timeZone").innerHTML = tz;
     }
     </script>

Outcomes