Overview
The Employee GPS Tracking feature enables real-time location monitoring of employees during their work shifts. Using browser-based geolocation APIs, the system automatically captures and records employee positions at regular intervals, providing administrators with accurate attendance data and location history.This feature uses the HTML5 Geolocation API and requires users to grant location permissions in their browser.
How It Works
Employee Initiates Tracking
Employees log into the system and click the “Iniciar Turno” (Start Shift) button to begin location tracking for their work session.
Automatic Location Capture
The system captures GPS coordinates every 50 minutes automatically using the browser’s geolocation API.
Data Storage
Each location ping is stored with the employee’s username, coordinates, date, and timestamp in the system’s database.
User Workflow
For Employees
- Login: Access the system using credentials
- Start Tracking: Click the “Iniciar Turno” button on the homepage
- Grant Permissions: Allow browser location access when prompted
- Monitor Status: View the last update timestamp to confirm tracking is active
The tracking button is disabled once activated to prevent accidental duplicate sessions.
Employee Interface
The employee tracking interface is simple and user-friendly:Technical Implementation
Geolocation API Usage
The system uses the HTML5 Geolocation API with high accuracy enabled:50-Minute Interval Strategy
Why 50 minutes?
Why 50 minutes?
The 50-minute interval balances several key factors:
- Battery efficiency: Reduces power consumption on mobile devices
- Data volume: Minimizes storage requirements while maintaining adequate coverage
- Network usage: Reduces bandwidth consumption for remote workers
- Sufficient monitoring: Provides enough data points during an 8-hour shift (approximately 9-10 location captures)
Backend Processing
The Flask backend receives and stores location data inapp.py:116-132:
Data Structure
Location Record Format
Each GPS ping is stored with the following structure:usuario
The employee’s username identifier
lat / lon
Latitude and longitude coordinates in decimal degrees format
fecha
Date in YYYY-MM-DD format for easy sorting and filtering
hora
24-hour format timestamp (HH:MM:SS) used for tardiness detection
Privacy & Security
Permission Requirements
Browsers require explicit user consent before accessing location data:- First-time users: Browser shows a permission prompt
- Denied permissions: System displays “Activa el GPS” alert
- High accuracy mode: Enabled for precise location capture
Troubleshooting
Location not updating
Location not updating
Common causes:
- GPS/location services disabled in browser or device
- No internet connection for data transmission
- Browser doesn’t support Geolocation API (very rare)
- Check browser location permissions
- Ensure stable internet connectivity
- Try a different browser (Chrome, Firefox, Safari recommended)
Inaccurate coordinates
Inaccurate coordinates
Common causes:
- Poor GPS signal indoors or in dense urban areas
- Device using WiFi-based location instead of GPS
- High accuracy mode not enabled
- Move to location with clear sky view
- Enable high accuracy in device location settings
- Wait for GPS lock before clicking “Iniciar Turno”
Integration with Other Features
The tracking system integrates seamlessly with:- Admin Dashboard: View all employee locations and attendance
- Automated Reminders: Detect who hasn’t started tracking by 8 AM
- PDF Reports: Include location history in downloadable reports