SOLVED

Email Script Token Help

Go to solution
LP_IMS_KJB_0412
Level 1

Email Script Token Help

Good afternoon,

 

I've created an Email Script Token ({{my.SFDC_Type}}) as follows:

 

#if( $lead.SFDC_Type.equals("Lead") )
	#set( $sfdcindicator = "1" )
#elseif( $lead.SFDC_Type.equals("Contact") )
	#set( $sfdcindicator = "2" )
#else
	#set( $sfdcindicator = "0" )
#end

${sfdcindicator}

 

The token is to be appended to email links as a querystring, e.g. https://www.companynam.com/global/en/corporate/?sfdc_type={{my.SFDC-Type}} and when the email is previewed, the URL renders as expected, e.g. https://www.companynam.com/global/en/corporate/?sfdc_type=1

 

LP_IMS_KJB_0412_1-1750334798301.png

 

However, when the email is sent, the value is not present in the email URL:

 

LP_IMS_KJB_0412_2-1750335575067.png

 

What might be the reason for this, especially because the value does display when the token is included in the email body:

LP_IMS_KJB_0412_4-1750335702764.png

 

 

LP_IMS_KJB_0412_3-1750335662725.png

 

Any help would be greatly appreciated.

 

Kind regards

 

Karl

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Token Help

Didn’t specifically mean Formula field. Use a standard Number field and set it nightly using Change Data Value w/choices. (Filter on people who’ve had changes to the underlying fields in the previous day.)

 

Also not sure why you’re adding Original Source Type in there. Someone who originated in Marketo can be synced to SFDC.

View solution in original post

5 REPLIES 5
Michael_Florin
Level 10

Re: Email Script Token Help

Your script works fine for me.

 

But you use my.SFDC-Type on your URL parameter, but the name of the token is my.SFDC_Type, isn't it?

SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Token Help

I wonder, like Michael says, if you don’t have a typo in this particular test.

 

But fundamentally, what you’re trying to do is not supported. You must output the entire <a> tag from Velocity, not just parts of the href. (In other words, you can’t piece together a URL from parts outside and inside Velocity.)

 

So you shouldn’t rely on this method either way — there have been many twists and turns over the years in what seems to work in Velocity vs. what’s guaranteed to work. Only outputting the entire <a> works, unless you disable tracking.

 

Also bear in mind SFDC Type isn’t meaningful unless you also check SFDC Is Deleted. For this task, I would have a separate calculated field instead of what you’re doing.

 

 

LP_IMS_KJB_0412
Level 1

Re: Email Script Token Help

Hi Michael and Sandford,

 

thank you both for your replies and apologies Michael, the initial reference to the program token was a typo and the correct name is {{my.SFDC-Type}} as referenced in the URL tests.

 

To Sandford's reply, I did come across feedback from yourself to another user with a similar use case. I conducted a subsequent successful test constructing the full <a> reference within the token.

 

This is great, but my use case in this instance is to append this parameter to all URLs in an email to serve Adobe Analytics reporting, specifically so users can distinguish between lead and contact web activity.

 

With this in mind, would the solution be to create an Email Script token for every distinct URL in an email as this feels cumbersome and would likely intimidate marketing users?

 

I did, as suggested create a calculated field, including the SFDC Is Deleted field within the logic, and appended that field as a token to a URL to test but I received the following error message:

 

Calculated Field:

LP_IMS_KJB_0412_0-1750430561877.png

 

Append to URL: 

LP_IMS_KJB_0412_2-1750430710042.png

 

Preview: 

LP_IMS_KJB_0412_3-1750430768681.png

 

Attempt to execute:

LP_IMS_KJB_0412_1-1750430655055.png

 

Any further ideas would be appreciated please.

 

Regards

 

Karl

SanfordWhiteman
Level 10 - Community Moderator

Re: Email Script Token Help

Didn’t specifically mean Formula field. Use a standard Number field and set it nightly using Change Data Value w/choices. (Filter on people who’ve had changes to the underlying fields in the previous day.)

 

Also not sure why you’re adding Original Source Type in there. Someone who originated in Marketo can be synced to SFDC.

LP_IMS_KJB_0412
Level 1

Re: Email Script Token Help

Thanks Sandford, apologies for the delay in responding. I can confirm that the suggestion to run a nightly smart campaign to maintain the field value works and this field in turn, can be successfully added as a querystring to email URLs.

 

Thank you very much for all the feedback.