SOLVED

Tokens for specfic document download links based on email address

Go to solution
Highlighted
Level 2

Tokens for specfic document download links based on email address

I'm trying to figure out a way to use Tokens to create specific document download links based on the email address/company.  I've already created each specific tokens to reference the different documents for each company... but I'm having difficulty figuring out how to get the token associated with the company name.

For example:

If email contains XYZ, then use My Token XYZ

If email contains ABC, then use My Token ABC

I'm thinking I need to create an email script - but this "velocity" scripting is above my understanding... Does anyone know of a simpler way of doing this or have sample email script that I can use to make this happen?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Tokens for specfic document download links based on email address

Unless you have already segmented by email domain (which is going to be impossible if you have > 100 domains and 100 different documents) you must use Velocity.

You don't need any separate tokens but a single Velocity token like so:

#define( $formatLink )<a href="http://${document}">Click to get your document!</a>#end

#set( $documentDomainMap = {

  "googlemail.com|gmail.com" : "www.example.com/google.pdf",

  "yahoo.com" : "www.example.com/yahoo.pdf",

  "hotmail.com" : "www.example.com/hotmail.pdf",

  "" : "www.example.com/default.pdf"

} )

## No need to edit below this line!

#foreach( $domainList in $documentDomainMap.keySet() )

#if( $lead.Email.matches( ".*@(${domainList})$" ) )

#set( $document = $documentDomainMap[$domainList] )

#break

#end

#end

## Use default if domain not found

#if( !$document )

#set( $document = $documentDomainMap[""] )

#end

${formatLink}

As you can see, at the top of the code, you list the domains (the $documentDomainMap variable that maps domains to their documents) and you set up the final output link (<A> tag). You don't need to edit anything else. Also note the domain can be a pipe-delimited list of domains (if some domains will get the same document).

When you create this token make sure Email Address is selected in the right-hand tree (if you don't do this then Velocity can't see the value of lead.Email).

2016-11-10 22_03_51-Marketo _ Program Lab 09 (My Tokens) • Marketing Activities.png

View solution in original post

2 REPLIES 2
Highlighted

Re: Tokens for specfic document download links based on email address

Unless you have already segmented by email domain (which is going to be impossible if you have > 100 domains and 100 different documents) you must use Velocity.

You don't need any separate tokens but a single Velocity token like so:

#define( $formatLink )<a href="http://${document}">Click to get your document!</a>#end

#set( $documentDomainMap = {

  "googlemail.com|gmail.com" : "www.example.com/google.pdf",

  "yahoo.com" : "www.example.com/yahoo.pdf",

  "hotmail.com" : "www.example.com/hotmail.pdf",

  "" : "www.example.com/default.pdf"

} )

## No need to edit below this line!

#foreach( $domainList in $documentDomainMap.keySet() )

#if( $lead.Email.matches( ".*@(${domainList})$" ) )

#set( $document = $documentDomainMap[$domainList] )

#break

#end

#end

## Use default if domain not found

#if( !$document )

#set( $document = $documentDomainMap[""] )

#end

${formatLink}

As you can see, at the top of the code, you list the domains (the $documentDomainMap variable that maps domains to their documents) and you set up the final output link (<A> tag). You don't need to edit anything else. Also note the domain can be a pipe-delimited list of domains (if some domains will get the same document).

When you create this token make sure Email Address is selected in the right-hand tree (if you don't do this then Velocity can't see the value of lead.Email).

2016-11-10 22_03_51-Marketo _ Program Lab 09 (My Tokens) • Marketing Activities.png

View solution in original post

Level 2

Re: Tokens for specfic document download links based on email address

Thank you, thank you, thank you!  I think this will definitely work - I am testing it now.