CMS Development

JLetellier
Contributor

HTML in contact property to render email

SOLVE

We currently have Marketing Hub Enterprise and Operations Hub Enterprise subscriptions. I am not a developper myself, but we have the ressources to help with implementing your suggestions. My inquiry is for the following:

 

We are in the process of creating a custom email template via the Design Tool, that renders the details of an insurance quote.

 

These quotes, may have multiple insured products (ex. car insurance with multipe drivers), along with multiple clients associated to the same product (that are not in our contact database). The issue is they do not have a limit to the number of products, and for each product there could be a various number of insured people. All of which would need to be populated in our email without actually creating contacts in our CRM, and not all of the information will be associated to the contact properties (as we can't have 25 driver properties "in case" someone decides to have so many drivers on one car). 

 

Our initial thought, was to populate a contact property with HTML, and to use a personnalization token to render the email, based on that property. However, from multiple readings, and tests, it appears as though HTML in a contact property will not render the HTML, but simply inject the HTML code as is in the email. Therefore, does not work for what we would like to do. 

 

My next thought, which may not make any sense to the developpers out there, but it was to create a module that captures all the details of the insurance quote (ex. JSON), and then have the custom email template use the module containing the quote details to render in the email template.  I've been finding bits and pieces everywhere and trying to make sense of all my readings, but I am lost in the middle of nowhere, as I am not sure how all the pieces fit together (JSON, HTML, HUBL, CSS, JAVA...). Some of which work in emails, others don't, and If they do, how to connect them in my email, and their purpose or in which steps that each of these work together.

 

I know some "default modules" exist in HubSpot, and I've been trying to see how these could be adapted to do what I am looking for, but have yet to succeed (ex. line_items.module). 

 

I started exploring the HubDB option, but that would mean additionnal programming to supplement the HubDB table with the insurance quote details, and then the possibility of retrieving the insurance details from the HubDB based on the insurance quote number. However, there is still the issue of never having the same number of products, insured per product and the details of the insurance being different. Yet the email still needs to be clean and responsive. 

 

I know this is not the first thread on this type of issue, but I am in dire need of the HubSpot community to point me in the right direction. As the more information I gather, and read, the less I know what to do and if the information I found is actually useful for custom email templates. 

 

Any ideas on how my issue could be resolved ? Maybe the solution is taking me out of the equation, as I have no clue what I'm doing. Just know that I am learning and trying to fit the pieces together on my own, rather than saying "I just can't do it".  

 

"Give a man a fish, and he will be hungry again tomorrow, but teach him to catch a fish, and he will be fed for the rest of his life".

 

I am not looking for the final solution with the actual code, but at least a little push in the right direction or readings that will help me get my end result. 

 

Thanks in advance for your assistance on the matter.

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

HTML in contact property to render email

SOLVE

Hi @JLetellier ,

 

I see that we do not have the option to paste HTML in the property as we do have that functionality with module richtext fields.

Here is an example of how I retrieve deal and line item data and how I work with JSON in property fields:

{% set deal = crm_object("deal", deal.hs_object_id, "createdate,amount,my_json_property", false) %}
{% set lineitems = crm_associations(deal.hs_object_id, "HUBSPOT_DEFINED", 19, "limit=500", "description,quantity") %}

{% for lineitem in lineitems.results %}
  {{lineitem.description}}
  {{lineitem.quantity}}
{% endfor %}

{% set object = deal.my_json_property|fromjson %}

{{object.data}}

So if you have JSON stored in a single line text property, you can retrieve that data and turn it into an object with |fromjson.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

0 Upvotes
8 Replies 8
Jhenray
Member

HTML in contact property to render email

SOLVE

This is good for new develpoer. I was looking for same feature for my insurance website, will apply on websiate that hosted on wordpress.

0 Upvotes
webmikepdx
Participant

HTML in contact property to render email

SOLVE

I was also struggling to do this and contacted Support. They were able to request the functionality to include html in a Contact property and have this render properly in the email! I'm creating custom html tables for each customer based on their recent orders and upload a spreadsheet with the contact email and the html code in a new property I named HTML block. It now works after support made this change.

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

HTML in contact property to render email

SOLVE

Hi @JLetellier ,

 

I've created a bunch of custom modules for emails that use deals and line item data and have used several properties that contain JSON in those modules to show an overview of line items and additional data.

Would it help if I share that code with you?



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
JLetellier
Contributor

HTML in contact property to render email

SOLVE

I would definitely appreciate it. To see how it all comes together and how this could be adapted to our needs. Thanks 

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

HTML in contact property to render email

SOLVE

Oh I totally forgot about this new feature. Did you try this yet? Pretty sure that HTML stored in a richtext property should work.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
JLetellier
Contributor

HTML in contact property to render email

SOLVE

I gave it a try, just now. I added HTML to a RICHTEXT property and used the personnalization token for the property, and it displayed the HTML directly in the email. Doesn't seem to be working, unless I am doing something wrong.

0 Upvotes
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

HTML in contact property to render email

SOLVE

Hi @JLetellier ,

 

I see that we do not have the option to paste HTML in the property as we do have that functionality with module richtext fields.

Here is an example of how I retrieve deal and line item data and how I work with JSON in property fields:

{% set deal = crm_object("deal", deal.hs_object_id, "createdate,amount,my_json_property", false) %}
{% set lineitems = crm_associations(deal.hs_object_id, "HUBSPOT_DEFINED", 19, "limit=500", "description,quantity") %}

{% for lineitem in lineitems.results %}
  {{lineitem.description}}
  {{lineitem.quantity}}
{% endfor %}

{% set object = deal.my_json_property|fromjson %}

{{object.data}}

So if you have JSON stored in a single line text property, you can retrieve that data and turn it into an object with |fromjson.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
Phil_Vallender
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

HTML in contact property to render email

SOLVE

Hi @JLetellier 

 

I feel like the answer to your challenges are almost certainly within the realm of programmable email, which can be used to show a recipient data from HubDB and custom objects. However, you will almost certainly need an experienced developer to create the solution. 


Read more about programmable email here: Create programmable emails (BETA) 

 

Key things to consider with this sort of thing are:

 

  • How does HubSpot get the information that needs to be displayed
  • How can HubSpot display the information to the viewer

Hope this helps.

Phil Vallender | HubSpot Website Agency