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
... View more