Insert custom HTML to email template via API

Anonymous
Not applicable

Insert custom HTML to email template via API

Is there a way to add custom HTML to an email template via the API?

Example: I want to send a user a table of traffic sources to his website, for example
Direct: 30%
Organic: 20%
Paid: 30%
Social: 20%

I want to insert this table into the email template and trigger an email without using custom objects or email scripting.

 
Tags (1)
6 REPLIES 6
David_Desrosie2
Level 4

Re: Insert custom HTML to email template via API

Yes this is possible. We have recently built something very similar. Here is how you could set this up: 
- Create a standard program and add a my.token - (will be used to parse your html)
- Create your email alert and insert that token in the body of your email
- Build a smart campaign that will have a request campaign trigger (optional) , your user in the smaratlist filters, and send your email as a flow
- Use the API to trigger or shcedule the campaign and attach your HTML content within the token attribute. 

You could use the Request campaign or Schedule campaign API calls to execute the email send: 
http://developers.marketo.com/documentation/rest/request-campaign/
http://developers.marketo.com/documentation/rest/schedule-campaign/

David



 
Anonymous
Not applicable

Re: Insert custom HTML to email template via API

Great thanks. Are we supposed to attach the HTML in the "value" field in the request?
David_Desrosie2
Level 4

Re: Insert custom HTML to email template via API

Yes, 
You will have the HTML in the value.
Note that you should be using a Rich Text Token to ensure that your HTML does not remains intact once it is parsed in the program. 
 
Anonymous
Not applicable

Re: Insert custom HTML to email template via API

I see.
In the Schedule Campaign request, if my users are in the smart list, how will the HTML added thru the API be matched to the right lead?

In the Request Campaign I see we need to insert an array of leads, how is the content matched here? or do I have to make the call for each lead separately?
 
Anonymous
Not applicable

Re: Insert custom HTML to email template via API

This blog post should help answer your question about matching leads to content:

http://developers.marketo.com/blog/sending-an-email-with-dynamic-content-from-marketo-using-the-api/

David_Desrosie2
Level 4

Re: Insert custom HTML to email template via API

My understanding was that you where doing one HTML for multiple Leads, but from your previous comment is seems like it's one HTML per lead, right?

Do you have a large volume of leads/HTML combinations to deal with?
If so, then, the Request Campaign that Murtza Suggested might be your best option. My understanding is that you have only one Token value passed by API Call - so It would require 1 API call per lead. 

Another alternative could be tu store the HTML Data within the lead record. Then you can 1) update Lead with HTML using API 2) Request or schedule campaigns in batch. In this case (using lead field) I think you would be limited in the lenght of 3,200 characters and I'm not 100% sure how encoding-decoding could affect the structure. 

Cheers