Create Token that Links to a URL | Community
Skip to main content
New Participant
June 25, 2024
Solved

Create Token that Links to a URL

  • June 25, 2024
  • 2 replies
  • 2561 views

Hi everyone,

 

I'm relatively new to creating tokens in Marketo and could use some guidance. We're currently working on a recruiting nurture campaign where each lead is assigned a recruiting manager. We want to incorporate customized CTA buttons that link to each lead's respective recruiter's Calendly for booking.

 

Here's the challenge: I've developed a token to achieve this functionality, but it's not working as expected. When we test it, all leads seem to default to the same landing page instead of redirecting to their recruiter's Calendly link.

 

The field in Marketo that stores the recruiter's name is PC_Recruiter_Name, and I've verified that this field works correctly with other tokens. Specifically, the token I'm using for this field is: ${lead.PC_Recruiter_Name}.

 

Could anyone advise on how to properly set up a token so that it populates the correct Calendly URL based on each lead's recruiter? Additionally, how can we ensure that leads without an assigned recruiter are directed to a default landing page?

 

Thank you in advance for your help!

 

 

## Check the recruiter name and set the corresponding Calendly link #if(${lead.PC_Recruiter_Name} == "NAME HERE") #set($Calendly = "calendly.com/NAMEHERE") #elseif(${lead.PC_Recruiter_Name} == "SECOND NAME HERE") #set($Calendly = "calendly.com/SECONDNAMEHERE") #elseif(${lead.PC_Recruiter_Name} == "THIRD NAME HERE") #set($Calendly = "calendly.com/THIRDNAMEHERE") #else #set($Calendly = "LANDINGPAGEURL.com") #end ## Output the Calendly URL ${Calendly}

 

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

Always pursue a config-first coding approach in Velocity because it makes your code easier to follow and maintain. (And here on the Nation,  remember to use the Syntax Highlighter so it’s readable at all — I updated your post this time.)

 

Put the mapping between recruiters and URLs at the top. Use $display.alt to fall back when there’s no matching key.

 

#set( $recruiterPages = { "NAME HERE" : "calendly.com/NAMEHERE", "SECOND NAME HERE" : "calendly.com/SECONDNAMEHERE", "THIRD NAME HERE" : "calendly.com/THIRDNAMEHERE" } ) #set( $finalURL = $display.alt($recruiterPages.get($lead.PC_Recruiter_Name),"example.com/lp") ) ${finalURL}

 

2 replies

SanfordWhiteman
New Participant
June 26, 2024

The field in Marketo that stores the recruiter's name is PC_Recruiter_Name, and I've verified that this field works correctly with other tokens. Specifically, the token I'm using for this field is: ${lead.PC_Recruiter_Name}.


P.S. This isn’t a “token“, it’s the Velocity name of the field.

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 26, 2024

Always pursue a config-first coding approach in Velocity because it makes your code easier to follow and maintain. (And here on the Nation,  remember to use the Syntax Highlighter so it’s readable at all — I updated your post this time.)

 

Put the mapping between recruiters and URLs at the top. Use $display.alt to fall back when there’s no matching key.

 

#set( $recruiterPages = { "NAME HERE" : "calendly.com/NAMEHERE", "SECOND NAME HERE" : "calendly.com/SECONDNAMEHERE", "THIRD NAME HERE" : "calendly.com/THIRDNAMEHERE" } ) #set( $finalURL = $display.alt($recruiterPages.get($lead.PC_Recruiter_Name),"example.com/lp") ) ${finalURL}

 

New Participant
June 26, 2024

Thank you so much for replying. I've updated the Script Token to what you've provided (filling in the correct information) and when I run tests all of our prospects just get the URL to the default landing page. The Calendly links for the recruiters don't populate. Is there an additional step that I need to take?

Also, I appreciate you updating the post. This is my first time using this discussion board. 😊 I'm still not even sure how to use the Syntax Highlighter.

SanfordWhiteman
New Participant
June 26, 2024

Never use tests (samples) to test Velocity. Only use real emails. Tests do not get a complete Velocity context.