Control Dynamic Content Using HubL


We are using transactional emails in order to control the content of the email template based off of what our customers purchase (ex. a product in Seattle rather than New Orleans). Sending this dynamic content via JSON objects results in our templates referencing JSON parameters in the form of "{{custom.[propertyName]}}" rather than "{{content.[contactField]}}." Based of the documentation I have read, HubL does not support these custom parameters. As a result, I am wanting to use HubL to reference the content of an HTML tag by referencing an id value.

For example, if one of the custom properties within the JSON object is sent as a blank string (""), we would want to display some other content within the email template using HubL logic. If the custom property is displaying within an HTML image tag, we would use an id on the image tag in the following form:

Since we cannot reference {{custom.imageProperty1}} within HubL, could we reference the id instead?


Hi @McKenzieMurphy, the field {{ custom.[propertyName] }} refers to properties included in the customProperties field as per the docs here if you are using the single send api: Any conditional logic would need to be handled on your servers before sending the data to HubSpot via API. If you're just using the transactional email without using single-send, it is pretty cut and dry with no conditional options allowed. HubL conditionals are not supported in emails at this time per this article. If statements do not work inside an email based on token information, which has to do with order of operations -- the if statement is executed before the token information gets filled in.