A Flask-based pixel tracker for email marketing using Hashlib, MongoDB, Redis, and Celery.
This application provides a simple HTTP pixel tracking system to monitor email opens. It generates SHA1-hashed event records using Python's hashlib
, stores data in MongoDB, and processes tasks asynchronously with Celery and Redis.
- Generates SHA1-hashed pixel URLs for tracking email opens
- Stores tracking data in MongoDB
- Asynchronous task processing with Celery and Redis
- Flask web server for API and pixel delivery
- Lightweight and easy to integrate into email marketing campaigns
- Python 3.8+
- Redis Server
- MongoDB Server
- Python dependencies:
pip install -r requirements.txt
- Clone the repository:
git clone https://github.com/craigderington/sha1-ip-pixel-tracker.git
- Navigate to the project directory:
cd sha1-ip-pixel-tracker
- Install system dependencies:
sudo apt-get install redis-server mongodb python-virtualenv
- Install Optional Tools
sudo apt-get install build-essential python-dev python-imaging
- Create and activate a virtual environment
virtualenv .env --python=python3 source .env/bin/activate
- Install Python Dependencies
pip install -r requirements.txt
- Start Redis and MongoDB Servers
sudo service redis-server start sudo service mongodb start
- Launch the Celery worker
celery -A pfpt.main.celery worker --loglevel=INFO --concurrency=1
- Run the Flasdk application
python pfpt/main.py
- Generate a tracking pixel URL:
curl "http://localhost:5000/api/generate-pixel?job_number=<job>&client_id=<client>&campaign=<campaign>"
- Embed the pixel in your email:
<img src="http://<your-url-dot-com>/pixel.gif?sh=<open_hash_id>" />
- When the pixel is opened, the pixel request records the event in MongoDB.
The application resides in the pfpt directory and includes:
- Flask App (main.py): Handles API endpoints for pixel generation and tracking.
- Celery Tasks: Processes tracking events asynchronously.
- MongoDB Storage: Stores event data with SHA1-hashed identifiers.
- Redis: Manages task queue for Celery.
- Hashlib: Generates SHA1 hashes for unique event tracking.
Contributions are welcome! To contribute:
- Create a feature branch (git checkout -b feature/your-feature).
- Commit your changes (git commit -m "Add your feature").
- Push to the branch (git push origin feature/your-feature).
- Open a pull request.
See the wiki for more details Wiki
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, contact Craig Derington.