SOLVED

Re: Using 40+ Custom Tokens in Velocity Script: Risks and Considerations

Go to solution
GowthamNataraj1
Level 1

I understand that there's a limit of 40 custom field tokens that can be used directly in a Marketo email. If this limit is exceeded, Marketo throws an error indicating that the token limit has been crossed.

 

I'm curious whether using more than 40 custom tokens in a Velocity Script could cause any issues, such as dynamic content not displaying correctly or email delivery failures.

 

In my specific use case, I'm currently using 42 custom consent field tokens within if-elseif statements to conditionally show or hide the unsubscribe link in the email footer.

 

Has anyone had experience working with Velocity Scripts in Marketo and encountered issues when using more than 40 custom tokens? I'd appreciate any insights or best practices.

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

The limit doesn't apply to $variables (which are not tokens) in Velocity.

View solution in original post

8 REPLIES 8
SanfordWhiteman
Level 10 - Community Moderator

The limit doesn't apply to $variables (which are not tokens) in Velocity.

GowthamNataraj1
Level 1

Hi @SanfordWhiteman 

During my testing, emails using Velocity scripting with a large number of custom field variables (tokens) were not delivered. In my case, I used 42 custom field variables.
I added a 1-minute wait step before the Send Email step, and then the email was sent successfully. However, this only worked when the trigger was a data value change.
I also tested other triggers such as web form fill - custom activity, and program status change, but in those cases, the email was not sent.
As a result, there seem to be inconsistencies in email delivery when using many custom field variables.
I created another email with only a few custom field variables (around 5), and it was sent and delivered every single time.
Based on your experience, is this kind of inconsistency expected when using Velocity scripting with many tokens, or is it something unusual?

 

Thank you

SanfordWhiteman
Level 10 - Community Moderator

Clearly something’s wrong with your test setup, i.e. it’s depending on other parts of your config and you don’t realize that’s why the Send Email is being skipped. Examine your Smart List qualification rules and communication limits.

 

We have emails with 150+ lead fields (again, not 150 my.tokens, 150 fields in the Velocity context). There’s no variation by type of trigger.

 

P.S. That Wait step isn’t doing anything. Marketo doesn’t try to assemble the email until it gets to the Send Email so you’re not letting it “prepare” or anything like that.

GowthamNataraj1
Level 1

@SanfordWhiteman

It appears there is an issue with the Velocity script. Within the script, I'm checking whether the consent fields are set to true in order to display the unsubscribe link. When none of the consent fields are set to true, the email is skipped in the flow step I believe. I'll review the code again and try to fix it.

One more thing I'd like to confirm with you: when a bulk email is sent—for example, to 50,000 records—does the Velocity script render the content properly? I'm asking because support mentioned that the email might fail to send.

SanfordWhiteman
Level 10 - Community Moderator

when a bulk email is sent—for example, to 50,000 records—does the Velocity script render the content properly? I'm asking because support mentioned that the email might fail to send.

Wow, that’s a bizarrely incorrect thing for them to say. We send Velocity-powered emails regularly to hundreds of thousands of people. Moreover, Marketo emails use Velocity Template Language under the hood even without userland {{my.tokens}}. So you’re never not using Velocity.

 

Now is it true that the more fields you have in the Velocity context — or more directly, the larger the size of the context, which means the longer the actual values of string/textarea fields for a lead — the longer the email could take to assemble? And can you write complex VTL functions that takes longer to execute? Sure. But we’re talking about the difference between a half-second and 2 seconds.

GowthamNataraj1
Level 1

@SanfordWhiteman 

Thank you for sharing your experience. I understand that VTL itself shouldn't cause any issues.

Marketo Support shared the knowledge base link below, stating that the limit applies to VTL and that the email could fail to send if exceeded. However, it's hard for me to accept this blindly, especially since VTL is designed to handle advanced logic and overcome limitations — such as those we face with segmentation.

Custom Field Limit for Velocity Tokens - Marketing Nation

 

In my case, the Velocity script is around 50KB in size and uses one #foreach loop along with 40 #if-#elseif statements to check Boolean fields. I believe the functions I'm using are not particularly complex.

 

Do you have any further thoughts on the above?

 

Thanks!

GowthamNataraj1
Level 1

@SanfordWhiteman

There were no issues with the Velocity Script. The records were marked as "Marketing Suspended" and will be removed once the email is verified. I didn’t set the email as operational, so Marketo skipped the flow step. Thankfully, there was nothing major.

 

Could you please confirm my question regarding the bulk send, based on your experience?

 

Thanks!

GowthamNataraj1
Level 1

Hi @SanfordWhiteman 

To add further context to my testing regarding the email not being sent — it appears that Marketo is skipping the "Send Email" step and proceeding to the next step. Why would Marketo skip this step?

Thank you!