SOLVED

Re: Create Token that Links to a URL

Go to solution
ccoleman
Level 1

Create Token that Links to a URL

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}

 

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Create Token that Links to a URL

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}

 

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Create Token that Links to a URL

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}

 

ccoleman
Level 1

Re: Create Token that Links to a URL

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
Level 10 - Community Moderator

Re: Create Token that Links to a URL

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

ccoleman
Level 1

Re: Create Token that Links to a URL

Coming back to simply thank you! Lots of human error involved on my end. Here's what my issue was after you provided the correct code:

 

IMPORTANT: On the right "Integration" pane, you have to check the box next to any field used in your token code!  Otherwise, Marketo will not be able to access that field when running the script.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create Token that Links to a URL


On the right "Integration" pane, you have to check the box next to any field used in your token code!  Otherwise, Marketo will not be able to access that field when running the script.

Quite so!

 

By the way, the reason Marketo doesn’t automatically export every field into the Velocity context is it would be a huge waste of resources. Some instances have thousands of fields and hundreds of Custom Objects; to export all of those for every lead on every send would kill performance.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create Token that Links to a URL


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.