Velocity script allows you to create tokens with multiple values that can change based on segmentation. For more general information on velocity script check out these articles:

https://www.linkedin.com/pulse/introduction-velocity-scripting-sample-project-gursimran-singh/

https://jennamolby.com/velocity-scripting-in-marketo-examples/

How to create a Dynamic Button token in Marketo

Open the relevant program or folder, select My Tokens and drag in a new email script token

Give your token a name and click 'edit' to bring up the token edit screen

Velocity script uses the following basic commands:

'#if' - this is used to start an 'if' statement.

'#set' - allows you to set/update the variable value.

'#elseif' - allows to perform diff. actions based on diff. conditions

'#end' - end the script

'##' - adding a comment

If you wanted to set up a button URL that would change based on the recipients country it would look like this:

#if(${lead.Country} == "Canada")

https://en.wikipedia.org/wiki/Canada

#elseif(${lead.Country} == "USA")

https://en.wikipedia.org/wiki/USA

#else

https://en.wikipedia.org/wiki/World

#end

To add fields to your script first click the check box next to the field you want to add and then drag it into the editing area. This step is important as if you don't click the check box than Marketo won't be able to properly identify the token.

The above script will change the link value if the recipient's country is Canada or the USA. The #else part tells Marketo what to do if the recipient is not from either Canada or the USA. In that situation the link will be https://en.wikipedia.org/wiki/World

When you have finished creating your script just save it and copy the token name. Then all you need to do it paste the token name into the button link builder in Knak.

If you need the button title to be dynamic you can create a second token for that as well.

Did this answer your question?