visibility
code
Python
verified
Free Download
devices
Cross-platform
code Code Preview
Python#!/usr/bin/env python3
"""
Tracking Pixel Generator
Generate self-hosted open tracking pixels for emails
"""
import base64
import hashlib
from urllib.parse import urlencode
# 1x1 transparent GIF
PIXEL_GIF = base64.b64decode(
'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
)
def generate_tracking_id(campaign_id, recipient_email):
"""Generate unique tracking ID"""
data = f"{campaign_id}:{recipient_email}"
return hashlib.sha256(data.encode()).hexdigest()[:16]
def generate_pixel_url(base_url, campaign_id, recipient_email):
"""Generate tracking pixel URL"""
tracking_id = generate_tracking_id(campaign_id, recipient_email)
params = {
'c': campaign_id,
't': tracking_id
}
return f"{base_url}/track/open.gif?{urlencode(params)}"
def generate_pixel_html(pixel_url):
"""Generate HTML for tracking pixel"""
return f''
def generate_batch(base_url, campaign_id, recipients):
"""Generate tracking pixels for multiple recipients"""
pixels = []
for email in recipients:
url = generate_pixel_url(base_url, campaign_id, email)
html = generate_pixel_html(url)
pixels.append({
'email': email,
'url': url,
'html': html
})
return pixels
if __name__ == '__main__':
base_url = 'https://track.yourdomain.com'
campaign = 'campaign_2024_01'
recipient = 'user@example.com'
url = generate_pixel_url(base_url, campaign, recipient)
print(f"Tracking URL: {url}")
print(f"HTML: {generate_pixel_html(url)}")
info About This Tool
The Tracking Pixel Generator creates invisible 1x1 pixel images for tracking email opens. Self-host your tracking for privacy and full control over your analytics data.
Key Features
- Unique Tracking IDs - SHA256 hashed identifiers per recipient
- Self-Hosted - Full control over tracking data
- Batch Generation - Create pixels for entire campaigns
- Privacy-Friendly - No third-party tracking services
- Transparent GIF - Invisible 1x1 pixel image
How It Works
- Generate unique pixel URL for each recipient
- Embed pixel in email HTML (usually before closing body tag)
- When recipient opens email, pixel loads from your server
- Server logs the open with timestamp and recipient info
Requirements
- Python 3.7+
- Web server to host tracking endpoint
- No external Python dependencies
Note: Tracking pixels are blocked by some email clients. Combine with link tracking for more accurate analytics.
download Download Script
Need Full Automation?
Try Postigo for automated email campaigns with AI personalization
rocket_launch Start Free Trial