Guide to adding a 1-pixel image to track email opens and including an unsubscribe option for users
Back to ezymailAdding a 1-pixel image to confirm that a recipient has opened an email, and adding an unsubscribe link so the recipient can stop receiving similar emails, are two standard parts of email marketing. In the current system, both features are already supported, so the main task is simply inserting the correct HTML into the email template.
Why These 2 Elements Matter
A 1-pixel image is a tiny invisible image loaded when the email is opened. Once the image is requested, the system can record that the email has been read. This is a common way to estimate email open rate.
An unsubscribe link gives recipients a clear way to stop receiving similar emails in the future. When the recipient clicks the link, the system stores their unsubscribe request and skips that email address in later sends for the same template.
What the System Already Supports
The system already provides 2 endpoints that can be used inside the email content:
- Read tracking URL:
/ezymail/api/v1/mail/read?contentId=... - Unsubscribe URL:
/ezymail/api/v1/mail/unsubscribe?contentId=...
Here,
contentId is the unique ID of each email. When the email is sent through the template flow, the system automatically generates this value so it can be used inside the HTML.
How to Add the 1-Pixel Tracking Image
Insert the following code near the end of the email body, usually just before
</body>:<img src="https://your-domain.com/ezymail/api/v1/mail/read?contentId=${contentId}" width="1" height="1" alt="" style="display:block;width:1px;height:1px;border:0;opacity:0;" />
What this does:
-
srcpoints to the endpoint that records the email open event. -
${contentId}identifies the exact email being opened. -
width="1"andheight="1"keep the image at 1 pixel. -
opacity:0makes it effectively invisible to the reader.
How to Add the Unsubscribe Link
You should place the unsubscribe link in the email footer so recipients can easily find it. For example:
<p style="font-size:12px;line-height:18px;color:#666;"> If you no longer want to receive this email, <a href="https://your-domain.com/ezymail/api/v1/mail/unsubscribe?contentId=${contentId}"> click here to unsubscribe </a>. </p>
When the recipient clicks this link, the system records the unsubscribe request. Future emails for the same template will skip that email address.
Complete HTML Email Example
Below is a full HTML email example that includes both the 1-pixel tracking image and the unsubscribe link:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Special Offer</title> </head> <body style="margin:0;padding:0;background-color:#f4f6f8;font-family:Arial,sans-serif;color:#222222;"> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#f4f6f8;margin:0;padding:0;"> <tr> <td align="center" style="padding:32px 16px;"> <table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" style="width:600px;max-width:100%;background-color:#ffffff;border-radius:8px;overflow:hidden;"> <tr> <td style="background-color:#0b57d0;padding:24px 32px;text-align:center;"> <h1 style="margin:0;font-size:28px;line-height:36px;color:#ffffff;"> A Special Offer Just for You </h1> </td> </tr> <tr> <td style="padding:32px;"> <p style="margin:0 0 16px 0;font-size:16px;line-height:24px;"> Hello, </p> <p style="margin:0 0 16px 0;font-size:16px;line-height:24px;"> Thank you for your interest in our products. This week, you can enjoy a <strong>20% discount</strong> on our new subscription plan. </p> <p style="margin:0 0 24px 0;font-size:16px;line-height:24px;"> This offer is valid until <strong>December 31, 2026</strong>. Click the button below to learn more. </p> <table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:0 0 24px 0;"> <tr> <td align="center" style="background-color:#0b57d0;border-radius:4px;"> <a href="https://your-domain.com/special-offer" style="display:inline-block;padding:14px 24px;font-size:16px;line-height:20px;color:#ffffff;text-decoration:none;font-weight:bold;" > View the Offer </a> </td> </tr> </table> <p style="margin:0 0 16px 0;font-size:14px;line-height:22px;color:#555555;"> If you need any help, simply reply to this email or contact our customer support team. </p> </td> </tr> <tr> <td style="padding:24px 32px;background-color:#f8f9fb;border-top:1px solid #e5e7eb;"> <p style="margin:0 0 8px 0;font-size:12px;line-height:18px;color:#666666;text-align:center;"> You are receiving this email because you subscribed to updates from us. </p> <p style="margin:0;font-size:12px;line-height:18px;color:#666666;text-align:center;"> If you no longer want to receive these emails, <a href="https://your-domain.com/ezymail/api/v1/mail/unsubscribe?contentId=${contentId}" style="color:#0b57d0;text-decoration:underline;" > click here to unsubscribe </a>. </p> </td> </tr> </table> <img src="https://your-domain.com/ezymail/api/v1/mail/read?contentId=${contentId}" width="1" height="1" alt="" style="display:block;width:1px;height:1px;border:0;opacity:0;" /> </td> </tr> </table> </body> </html>
What You Need to Replace Before Using It
Before sending a real campaign, update these parts:
- replace
https://your-domain.comwith your actual system domain - update the email title
- update the promotional or campaign content
- update the CTA button link such as
https://your-domain.com/special-offer
However, you must keep
${contentId} unchanged in both places:
- inside the 1-pixel image URL for open tracking
- inside the unsubscribe URL so the system can identify the correct email
Variables Available in the Template
Based on the current implementation, when the email is sent through the template flow, the system provides at least these useful variables:
-
${contentId}: unique email identifier for tracking and unsubscribe -
${toEmail}: recipient email address
For this use case,
${contentId} is the most important variable.
Important Practical Notes
Open tracking is not always perfectly accurate. If the recipient’s email client blocks images, the system may not record the email as opened even if the recipient has read it. Because of that, open rate should be treated as an approximate metric.
For unsubscribe, the current behavior works best when one email is sent to one recipient. If one email is sent to multiple recipients at once, unsubscribe behavior is no longer reliable for each individual person. For marketing emails, it is best to send one email per recipient.
Also, if you are using the template flow,
${contentId} is prepared automatically by the system. If your marketing team is composing raw HTML through a different flow that does not use templates, the technical team may need to add support for this variable first.Final Checklist Before Sending
- Use a full absolute URL with the correct domain
- Keep
${contentId}unchanged in both the tracking image and unsubscribe link - Place the unsubscribe link in the footer
- Place the 1-pixel image near the end of the email
- Prefer sending one email per recipient
- Test the email first with an internal address