SOLVED

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

Go to solution
lukea
Level 3

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

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

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

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

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.

lukea
Level 3

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

Cool, DM is out