Ways around the 100KB limit for Velocity scripts & proper JSON data serving | Community
Skip to main content
New Participant
February 7, 2021
Solved

Ways around the 100KB limit for Velocity scripts & proper JSON data serving

  • February 7, 2021
  • 1 reply
  • 2823 views

Greetings Marketo-Nation,

 

I often found myself exceeding the 100KB limit[1] for Velocity scripts in emails. Therefore, I wanted to ask for better ways to achieve what I am trying do to. (Not so much about polishing bits code, although I am happy to get advise there, too, but more after general strategy.)

 

What I am trying to do:

a.) Keep JSON-like data structures at a central place/token, e.g. for recommending next best actions [2].

b.) Pick proper elements from a.) for any individual email recipient, and make the elements' attributes accessible in Velocity variables [3].

c.) Turn the picks into HTML in order to display up to 10 recommendations in that email[4].

 

Why does it not scale/work:

Now, a.) and c.) bloat up the code pretty quickly beyond 100K Bytes.

  • For c.), because I cannot use a loop to display the recommendations; otherwise, the redirect/tracking links won't work.
  • And a.), because there are potentially alot (>200) of items to pick from, not to say that these could have more attributes than mentioned in the example.

Question:

Is there a better way of achieving this? For example, by storing a.) in a different way? 

 

Thanks in advance!


[1] https://developers.marketo.com/email-scripting/

 

[2]

 

 

## ################################# ## LIST OF POTENTIAL RECOMMENDATIONS ## ################################# #set( $assets = { "123": { "type": "A", "title": "foo", "image": "https://via.placeholder.com/350x150", "link": "amazon.com" }, "456": { "type": "B", "title": "bar", "image": "https://via.placeholder.com/350x150", "link": "google.com" } })

 

 

 

[3]

 

 

## ############################################### ## PICK RECOMMENDATIONS AND EVALUATE LIST ELEMENTS ## ############################################### #set( $recos = ['123', '456'] ) #foreach( $reco in $recos ) #if( $assets.containsKey($reco.toString()) ) #set( $DL = $assets[$reco.toString()] ) #evaluate( "${esc.h}set( ${esc.d}DL_${foreach.count} = ${esc.d}DL )" ) #end #end

 

 

 

[4]

 

 

## ####################### ## DISPLAY RECOMMENDATIONS ## ####################### #if( $DL_1 ) #if( $DL_1.link && !$DL_1.link.isEmpty() ) <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td class="fizz"> <a href="https://${DL_1.link}" target="_blank">Go there</a> </td> </tr> </table> #end #end #if( $DL_2 ) #if( $DL_2.link && !$DL_2.link.isEmpty() ) <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td class="fizz"> <a href="https://${DL_1.link}" target="_blank">Go there</a> </td> </tr> </table> #end #end

 

 

 

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

The logic to create trackable links, clumsy though it is (I'm not happy about it, even if I came up with the solution!) can't be thing that puts you over the limit. That is, if you're that close to 100KB you're too close as it is. So let's ignore (c).

 

For (a) I have a couple of suggestions, but would rather not enter them into the public record as they're for experienced Velocity users only (which you are). If you DM we can go over them.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
February 7, 2021

The logic to create trackable links, clumsy though it is (I'm not happy about it, even if I came up with the solution!) can't be thing that puts you over the limit. That is, if you're that close to 100KB you're too close as it is. So let's ignore (c).

 

For (a) I have a couple of suggestions, but would rather not enter them into the public record as they're for experienced Velocity users only (which you are). If you DM we can go over them.

lukeaAuthor
New Participant
February 8, 2021

Cool, DM is out