How to measure email opens and clicks programmatically
This marginal MCP tutorial walks through how to measure email opens and clicks programmatically — from launching a tracked send to reading lift metrics straight from your AI agent. No dashboard hopping, no spreadsheet exports.
What you need before you start
marginal is a hosted email marketing MCP server, so there is nothing to deploy. You connect an MCP-capable client to the endpoint, authenticate with a Bearer API key, and call tools directly from your agent.
- An MCP client such as Cursor, Claude Desktop, Claude Code, Windsurf, Cline, Continue, or Zed
- Your marginal API key (format: marg_live_...)
- The endpoint configured: https://marginal.sh/mcp
- A short list of recipients and at least one message to send
Step 1: Launch a tracked send
Open/click tracking is built into managed sends, so the act of launching is also the act of starting measurement. Use launch_test to fire a campaign — or a subject line A/B test if you want comparative numbers across variants.
If you are testing subject lines, generate options with generate_variants first, then pass them into launch_test. Each variant is tracked independently, which is what makes a meaningful subject line A/B test possible.
- generate_variants — produce candidate subject lines for your agent to test
- launch_test — send the campaign and begin recording opens and clicks
- Tracking is automatic; you do not configure pixels or redirect links by hand
Step 2: Read opens and clicks programmatically
Once a send is live, call get_results to measure email opens and clicks programmatically. The tool returns per-variant engagement and within-test lift metrics, so an AI agent email marketing workflow can compare performance without manual aggregation.
Because results come back as structured data, your agent can act on them directly — flag a winning variant, summarize engagement, or trigger follow-up logic in the same conversation.
- Open rate and click rate per variant
- Within-test lift so you can see relative performance, not just raw counts
- Data shaped for agents to parse and reason over
Step 3: Let the agent decide what to send next
Measurement is most useful when it feeds a decision. After get_results, call recommend_next to have marginal suggest the next move based on the opens and clicks you just measured. This closes the loop from send to insight to action.
The free tier covers 100 experiments per month, which is plenty to wire up and validate this flow end to end. See the full tool reference in the docs at https://marginal.sh/docs/ and the endpoint at https://marginal.sh/mcp.
- recommend_next — propose the follow-up send based on measured engagement
- Iterate quickly: generate, launch, measure, recommend, repeat
- 100 experiments/month on the free tier to prototype your how-to guide setup
Get started with marginal
marginal is a hosted email marketing MCP server at marginal.sh. Sign up free, create an API key, and connect https://marginal.sh/mcp from Cursor, Codex, or Claude Desktop.
- 100 experiments/month on the free tier
- Four MCP tools: generate_variants, launch_test, get_results, recommend_next
- Listed in the MCP Registry as sh.marginal/mcp