Skip to content

fix: improve tracking pixel HTML attributes for anti-spam compliance#3136

Merged
knadh merged 2 commits into
knadh:masterfrom
shustovTE:fix/tracking-pixel-attributes
Jul 12, 2026
Merged

fix: improve tracking pixel HTML attributes for anti-spam compliance#3136
knadh merged 2 commits into
knadh:masterfrom
shustovTE:fix/tracking-pixel-attributes

Conversation

@shustovTE

Copy link
Copy Markdown
Contributor

Problem

The current tracking pixel is rendered as a bare <img> tag without explicit size attributes:

<img src="https://..." alt="" />

This can trigger stricter anti-spam filters that look for tracking pixels without proper dimensional attributes, and doesn't follow best practices used by major ESPs.

Solution

Replace with a fully-attributed 1×1 invisible pixel:

<img src="https://..." width="1" height="1" style="display:none;max-height:0;max-width:0;opacity:0" alt="">

Benefits

  • width="1" height="1" — explicit HTML dimensions satisfy email client validators and prevent the image from being rendered as a broken/empty image in some clients
  • display:none — hides the pixel in all modern email clients that support CSS
  • max-height:0;max-width:0 — redundant hiding for clients that partially support CSS (e.g. older Outlook)
  • opacity:0 — additional layer of invisibility for clients that may ignore display:none
  • Consistent with tracking pixel best practices used by Mailchimp, SendGrid, and other major ESPs
  • No functional changes — tracking still works identically; only the HTML markup is improved

Changed file

internal/manager/manager.goTrackView template function

shustovTE added 2 commits July 8, 2026 11:45
Replace the bare <img src="..." alt="" /> tracking pixel with a
standardized 1x1 invisible pixel that includes explicit dimensions
and CSS visibility properties.

Before:
  <img src="..." alt="" />

After:
  <img src="..." width="1" height="1" style="display:none;max-height:0;max-width:0;opacity:0" alt="">

Benefits:
- Explicit width/height="1" satisfies HTML validators and email
  clients that expect dimensional attributes for tracking pixels
- CSS style properties (display:none, max-height/width:0, opacity:0)
  provide redundant hiding across different email clients
- Better compatibility with strict anti-spam filters that flag
  pixels without proper size attributes
- Follows common best practices used by major ESPs (Mailchimp,
  SendGrid, etc.)
The drawTransparentImage call was using hardcoded non-standard dimensions
(width=14, height=3) for the tracking pixel PNG served at /px.png.

Change to the canonical 1x1 transparent PNG, which is the industry
standard used by all major ESPs (Mailchimp, SendGrid, etc.).

This is backward-compatible: the pixel URL in already-sent emails
(/campaign/:campUUID/:subUUID/px.png) does not encode image dimensions —
only UUIDs. The server-side tracking logic is unchanged; only the binary
payload of the PNG response is smaller and correct.
shustovTE added a commit to shustovTE/listmonk that referenced this pull request Jul 8, 2026
- cmd/public.go: change drawTransparentImage(3, 14) → drawTransparentImage(1, 1)
  Tracking pixel PNG was being generated with non-standard 14×3 dimensions.
  Changed to the canonical 1×1 transparent PNG (industry standard).

- internal/manager/manager.go: add width/height/style to TrackView img tag
  The generated <img> tag lacked explicit width="1" height="1" and
  display:none style, which caused some email clients to request a
  full-size image placeholder and show a broken image icon.

This is the fix backported to v6.2.0 for the custom v6.2.1 release.
See upstream PR knadh#3136.
shustovTE added a commit to shustovTE/listmonk that referenced this pull request Jul 8, 2026
release: v6.2.1 — fix tracking pixel (backport from upstream PR knadh#3136)
@knadh knadh merged commit 18b7459 into knadh:master Jul 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants