SOLVED

Re: Use Token on a Landing Page

Go to solution
DanielSchneider
Level 1

Use Token on a Landing Page

Hello,

 

I am creating a Landing Page for a Webinar which hat two Sessions in different time zones. After filling out a form, dependent on the Session, I would like to show the matching day, time, et cetera. I have created a token which I use in an email. Is it possible to adjust the token to use it on a Landing Page?

This is the token I wrote:

 

#if($lead.personalizationtrigger2.matches("Session 1"))
<p><strong>Wochentag Tag.Monat 2024 Session 1<br />
Region Session 1<br />
Uhrzeiten Session 1</strong></p>
#end
#if($lead.personalizationtrigger2.matches("Session 2"))
<p><strong>Wochentag Tag.Monat 2024 Session 2<br />
Region Session 2<br />
Uhrzeiten Session 2</strong></p>
#end

 

The custom field personalizationtrigger2 is already created.

I hope my idea can be realized.

3 ACCEPTED SOLUTIONS

Accepted Solutions
DD-Yasin
Level 2

Re: Use Token on a Landing Page

How do the leads choose the sessions? 

This might not be exactly what you want, but why dont you just create 2 different Follow Up pages: one for related content of seminar 1 and one for seminar 2.
If you are using fields to determine the sessions, you can just edit the follow-up settings with additional choices:

If [customField] is [fieldValue] -> Follow Up with [...]

DDYasin_0-1722955748375.png

 

 

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

It's quite simple. You first attach the field to the Thank You URL (in the query string):

MktoForms2.whenReady(function(readyForm) {
   readyForm.onSuccess(function(submittedValues, originalThankYouHref) {
      let thankYouURL = new URL(originalThankYouHref);
      thankYouURL.searchParams.set("personalizationtrigger2", submittedValues["personalizationtrigger2"]);
      document.location.href = thankYouURL.href;
      return false;
   });
});

 

Then on the Thank You LP, set your HTML up with easily findable attributes:

<p id="session-details">
   <span class="name"></span><br>
   <span class="region"></span><br>
   <span class="time"></span>
</p>

 

And when the Thank You LP loads, read the query params and populate the elements from a local mini-dictionary:

document.addEventListener("DOMContentLoaded",function(e){
   let sessions = {
      "Session 1" : {
         name: "Wochentag Tag.Monat 2024 Session 1", 
         region: "Region Session 1",
         time: "Uhrzeiten Session 1"
      },
      "Session 2" : {
         name: "Wochentag Tag.Monat 2024 Session 2", 
         region: "Region Session 2",
         time: "Uhrzeiten Session 2"
      }
   };

   let currentURL = new URL(document.location.href);
   
   if(currentURL.searchParams.has("personalizationtrigger2")) {     
      let session = sessions[currentURL.searchParams.get("personalizationtrigger2")];
      
      document.querySelector("#session-details .name").innerHTML = session.name;
      document.querySelector("#session-details .region").innerHTML = session.region;
      document.querySelector("#session-details .time").innerHTML = session.time;
  }
})

 

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

Btw, forgot to mention that your Velocity has a bug as well. You should be using .equals(), not .matches().

View solution in original post

10 REPLIES 10
SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

Let’s step back from the word “token” as that is itself an assumption about what feature to use.

 

Are you talking specifically about displaying content, based on the value of a form field, on the same page as the form? Or on an immediate follow-up/Thank You page?

DanielSchneider
Level 1

Re: Use Token on a Landing Page

I want to show two different times for the webinar on a thank you page after a person filled out the form.

The logic is landing page with form -> the custom field personalization trigger 2 is set to seminar 1 or seminar 2 -> I want to display the related content of seminar 1 or seminar 2 on a Thank You page.

DD-Yasin
Level 2

Re: Use Token on a Landing Page

How do the leads choose the sessions? 

This might not be exactly what you want, but why dont you just create 2 different Follow Up pages: one for related content of seminar 1 and one for seminar 2.
If you are using fields to determine the sessions, you can just edit the follow-up settings with additional choices:

If [customField] is [fieldValue] -> Follow Up with [...]

DDYasin_0-1722955748375.png

 

 

DanielSchneider
Level 1

Re: Use Token on a Landing Page

Thanks for all of your suggestions. After internal discusccion, we decided to use this solution with two Thank You Pages and the follow-up settings with additional choices.

SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

It's quite simple. You first attach the field to the Thank You URL (in the query string):

MktoForms2.whenReady(function(readyForm) {
   readyForm.onSuccess(function(submittedValues, originalThankYouHref) {
      let thankYouURL = new URL(originalThankYouHref);
      thankYouURL.searchParams.set("personalizationtrigger2", submittedValues["personalizationtrigger2"]);
      document.location.href = thankYouURL.href;
      return false;
   });
});

 

Then on the Thank You LP, set your HTML up with easily findable attributes:

<p id="session-details">
   <span class="name"></span><br>
   <span class="region"></span><br>
   <span class="time"></span>
</p>

 

And when the Thank You LP loads, read the query params and populate the elements from a local mini-dictionary:

document.addEventListener("DOMContentLoaded",function(e){
   let sessions = {
      "Session 1" : {
         name: "Wochentag Tag.Monat 2024 Session 1", 
         region: "Region Session 1",
         time: "Uhrzeiten Session 1"
      },
      "Session 2" : {
         name: "Wochentag Tag.Monat 2024 Session 2", 
         region: "Region Session 2",
         time: "Uhrzeiten Session 2"
      }
   };

   let currentURL = new URL(document.location.href);
   
   if(currentURL.searchParams.has("personalizationtrigger2")) {     
      let session = sessions[currentURL.searchParams.get("personalizationtrigger2")];
      
      document.querySelector("#session-details .name").innerHTML = session.name;
      document.querySelector("#session-details .region").innerHTML = session.region;
      document.querySelector("#session-details .time").innerHTML = session.time;
  }
})

 

DanielSchneider
Level 1

Re: Use Token on a Landing Page

Ok, unfortunately I'm not a pro like you in Marketo and I don't have the access rights to change anything on the code of the Landing Page. Is there a possibility that works if only superficial changes can be made? Otherwise you would probably have to work with two Thank You pages.

SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

You don't have the ability to alter HTML, either? I find it surprising that your admin lets you author Velocity tokens, but doesn't let you add JS or change HTML. Have you discussed this business case with them?

SanfordWhiteman
Level 10 - Community Moderator

Re: Use Token on a Landing Page

Btw, forgot to mention that your Velocity has a bug as well. You should be using .equals(), not .matches().

DanielSchneider
Level 1

Re: Use Token on a Landing Page

Thank you for your input. But the token has already been tested and works in an email 😊