Skip to main content
← Back to Recipes

Embed chart in Mailchimp campaign

Generate a chart URL and use it in a Mailchimp campaign via an image block or merge tag.

1. Render chart with returnUrl

javascript
const res = await fetch('https://www.chart-output.com/api/v1/render', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.CHART_OUTPUT_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ type: 'line', data: { labels: ['Jan','Feb','Mar'], datasets: [{ data: [10,20,30] }] }, returnUrl: true, }), }); if (!res.ok) throw new Error(await res.text()); const { url } = await res.json();

2. Use in Mailchimp

html
<img src="*|CHART_URL|*" alt="Monthly stats" width="600" height="300" />

Pass url as a merge tag value when sending the campaign.