<?php
/**
 * Tracking Include File
 * Include this at the top of any page to track visitors
 *
 * Usage: require_once 'includes/track.php';
 */

// Only track if not already tracking
if (!defined('VISITOR_TRACKING_ACTIVE')) {
    define('VISITOR_TRACKING_ACTIVE', true);

    // Determine site name
    $trackingSite = 'landsales';
    if (strpos($_SERVER['HTTP_HOST'] ?? '', 'landsecure') !== false &&
        strpos($_SERVER['HTTP_HOST'] ?? '', 'landsalespro') === false) {
        $trackingSite = 'landscanner';
    }

    // Include tracker if DB connection exists
    if (isset($conn) && $conn) {
        require_once __DIR__ . '/visitor_tracker.php';
        $trackingData = trackVisitor($trackingSite);
    }
}
