Add AMPScript-like support for math calculations on email templates

0 Likes

Add AMPScript-like support for math calculations on email templates

This is a bit of an odd request, but hopefully I can explain this without making this too abstract.

 

When working with email templates, there's no way to do dynamic calculations based on defined variable values. For example, if you were going to write some dynamic CSS for calculating size for a landing page, you might do something like:

 

 

width: calc(100vw - 20px);

 

 

in order to calculate the pixel width of the viewport width, minus 20 pixels. That sort of calculation can't be done with email markup in a widely supported way. However, other templating languages can support this sort of work. AMPScript's math functions can handle this sort of work for doing on-the-fly calculations for email. This technique can be used to enable certain dynamic features when paired with Marketo's template syntax, and I'm happy to provide private examples of how this would be used. Unfortunately, this is not a use case scenario where doing calculation inside Velocity and then having a token perform adjustment would work—this needs the ability to read from variables set in the email itself.