About this project
## Overview
Web Visitor Analytics for Telegram is a server-side Python monitoring module designed to integrate into Python-based web applications (Flask, Django, or any Python backend). It provides real-time visitor alerts through the Telegram Bot API, enriching each notification with geolocation and ISP data derived from the public IP-API service.
It is not a standalone application — the provided snippet must be pasted into your main application file (e.g., `app.py`) so that it executes alongside your existing route handlers.
## Features
- **Real-time Telegram Notifications:** Instant alerts are dispatched every time a page is accessed, delivering structured visit summaries directly to a designated Telegram user or chat.
- **Geolocation Data:** Automatically resolves the visitor's city, country, and ISP by querying IP-API using the request's originating IP address.
- **Non-Blocking Integration:** The module incorporates error handling so that failures in the tracking API or Telegram delivery do not disrupt the main application flow.
- **Privacy-Conscious Display:** Full IP addresses are partially masked in notifications to reduce exposure while still providing useful identification.
## Requirements
- Python
- The `requests` library (`pip install requests`)
- A Telegram Bot token obtained from @BotFather
- Your personal Telegram Chat ID, retrievable from @userinfobot
## Installation & Setup
1. Create a bot via @BotFather on Telegram and save the API token.
2. Obtain your Chat ID from @userinfobot.
3. Paste the integration snippet into your project's main entry point (e.g., `app.py`).
4. Replace the placeholder token and chat ID values with your own — ideally via environment variables rather than hardcoding them.
```
pip install requests
```
## Compatibility Notes
This module is written purely in Python. It works with Flask and Django out of the box and can be adapted to any Python backend. It will not run on static HTML sites or non-Python environments without porting the logic to those languages.
## Important Disclaimers
- **Geolocation Accuracy:** Locations are determined by the visitor's ISP network routing, not GPS coordinates. A user may appear to be in a different city than their physical location depending on how their provider routes traffic.
- **Privacy & Legal Compliance:** The tool collects and transmits IP-derived data. Users are responsible for complying with applicable privacy regulations such as GDPR or CCPA. Use ethically and responsibly.
- **Security:** Never hardcode bot tokens or chat IDs in public repositories. Use environment variables or a secrets manager.
## Use Case
The author uses this module in a private production portfolio website to monitor live visitor traffic and receive immediate security insights on their Telegram device. A sample notification shows the masked IP, ISP name, city, and country in a compact formatted message.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.