SOLVED

Re: Tokenized links rendering correctly on preview but not on real email

Go to solution
Victor_Herrero
Level 5

Tokenized links rendering correctly on preview but not on real email

 

 

Hi, 

 

I have been having an issue with links in some of our emails. The link contains an important parameter for an id that can be in two different fields but i don't know which, so I check both in the script token and get the first non-empty match. 

 

The link inside the email looks like this: 

{{my.ar_referral_url}}?ls=Referral&lsd=Au+Pair+Referral&utm_source=Referral&utm_medium=Email&utm_campaign=AR_direct+referral_AR+Referral+Campaign_PreDeparture&apid={{my.aupairID_master}}&reftype=Aupair&sfc=7013q000001kOgt&sfcs=Responded

 

 

The script token looks like this: 

 

## Returns the first populated Au Pair Id / Au pair
## from either the Lead, Contact, Account or Opportunity objects
##
##
## Define possible variables
## // Au Pair Number should be used instead of Au Pair ID,
## // since Au Pair ID can be different in Tellus sometimes 
#set($AupairNumber = "initial value")
#set($empty = "")
##
## Determine the first not empty value
#if(${lead.AP_Au_Pair_Number__c} != $empty)
	#set($AupairNumber=${lead.AP_Au_Pair_Number__c})
#elseif(${company.AP_Au_Pair_Number__c} != $empty)
    #set($AupairNumber=${lead.Au_pair_number__c})
#elseif(${OpportunityList.get(0).Au_Pair__c} != $empty)
    #set($AupairNumber=${OpportunityList.get(0).Au_Pair__c})
#else
    #set($AupairNumber = "unknown")
#end
##
## Return not empty value
$AupairNumber

 

 

And in preview renders correctly (valid url and 'apid' correclty rendered): 

OJvt00jPcR.png

But the real email either redirects to this in gmail when I click, before I replaced the first regular token with a splled-out url (url invalid)

 

chrome_7YSQrCEG9R.png

Or this after replacing the initial regular token (url valid but 'apid' is now empty)

KP60QcnkcX.png

 

Any insights into why this is happening? I deactivated link tracking as well for this link, since I already noticed that breaks links with script tokens 
Perhaps you @SanfordWhiteman ?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Tokenized links rendering correctly on preview but not on real email

Shouldn't compare to empty (nor use the == operator at all!) but rather use isEmpty():

## Returns the first populated Au Pair Id / Au pair
## from either the Lead, Contact, Account or Opportunity objects
##
##
## Define possible variables
## // Au Pair Number should be used instead of Au Pair ID,
## // since Au Pair ID can be different in Tellus sometimes 
#set($AupairNumber = "initial value")
##
## Determine the first not empty value
#if( $lead.AP_Au_Pair_Number__c.isEmpty() )
  #set( $AupairNumber = $lead.AP_Au_Pair_Number__c )
#elseif( $company.AP_Au_Pair_Number__c.isEmpty() )
  #set( $AupairNumber = $lead.Au_pair_number__c )
#elseif( $OpportunityList.get(0).isEmpty() )
  #set( $AupairNumber = $OpportunityList.get(0).Au_Pair__c )
#else
  #set( $AupairNumber = "unknown" )
#end
##
## Return not empty value
$AupairNumber

 

But that's not the problem — the prob is you must output the entire link, from <a> through </a> inclusive from Velocity. Links made partially from Velocity output aren't aren't supported.

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Tokenized links rendering correctly on preview but not on real email

Shouldn't compare to empty (nor use the == operator at all!) but rather use isEmpty():

## Returns the first populated Au Pair Id / Au pair
## from either the Lead, Contact, Account or Opportunity objects
##
##
## Define possible variables
## // Au Pair Number should be used instead of Au Pair ID,
## // since Au Pair ID can be different in Tellus sometimes 
#set($AupairNumber = "initial value")
##
## Determine the first not empty value
#if( $lead.AP_Au_Pair_Number__c.isEmpty() )
  #set( $AupairNumber = $lead.AP_Au_Pair_Number__c )
#elseif( $company.AP_Au_Pair_Number__c.isEmpty() )
  #set( $AupairNumber = $lead.Au_pair_number__c )
#elseif( $OpportunityList.get(0).isEmpty() )
  #set( $AupairNumber = $OpportunityList.get(0).Au_Pair__c )
#else
  #set( $AupairNumber = "unknown" )
#end
##
## Return not empty value
$AupairNumber

 

But that's not the problem — the prob is you must output the entire link, from <a> through </a> inclusive from Velocity. Links made partially from Velocity output aren't aren't supported.

Victor_Herrero
Level 5

Re: Tokenized links rendering correctly on preview but not on real email

Thanks so much for going over it Sanford! 

I'll redo things according to your feedback and see. 

Victor_Herrero
Level 5

Re: Tokenized links rendering correctly on preview but not on real email

Sorry Sanford, now that I realize what I need is a "isNotEmpty()" if something like that exists. I had a lot of trouble with VTL documentation to find the correct way to say "is empty" or is null. 

 

There are different answers here: 

https://cwiki.apache.org/confluence/display/VELOCITY/VelocityNullSupport

#if ($foo == null)
foo is null
#end

I don't think this worked at all in Marketo, feels like a different version of VTL ?

 

https://cwiki.apache.org/confluence/display/VELOCITY/CheckingForNull

In here the approach was similar, but I think it also didn't work for me

 

In the official documentation I have trouble finding how to check for null

https://velocity.apache.org/engine/1.7/vtl-reference.html

 

and also they mention this 

chrome_xH4VPZVmRA.png

but you say not to use "==" so that left me quite confused