Matomo Heartbeat !free! Review

destroy() this.stopHeartbeat(); if (this.idleCheckId) clearInterval(this.idleCheckId); this.log('Heartbeat destroyed');

$input = json_decode(file_get_contents('php://input'), true); $result = $handler->processHeartbeat($input); matomo heartbeat

resetIdleTimer() this.lastActivity = Date.now(); // If user becomes active again after idle if (!this.isActive && !document.hidden) this.startHeartbeat(); destroy() this

// Auto-initialize if Matomo is present if (typeof window._paq !== 'undefined') window.matomoHeartbeat = new MatomoHeartbeat( heartbeatInterval: 15, minVisitLength: 5, idleTimeout: 30, debug: window.location.hostname === 'localhost' ); if (this.idleCheckId) clearInterval(this.idleCheckId)

init() this.bindEvents(); this.startIdleMonitoring(); this.log('Matomo Heartbeat initialized');

sendBeacon(data) // Use sendBeacon for reliable final tracking if (navigator.sendBeacon) const formData = new FormData(); Object.keys(data).forEach(key => formData.append(key, data[key]); ); navigator.sendBeacon('/matomo.php', formData);

header('Content-Type: application/json'); echo json_encode($result); <!DOCTYPE html> <html> <head> <!-- Matomo Tracking Code --> <script> var _paq = window._paq = window._paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() var u="https://your-matomo-domain.com/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); )(); </script>

Back
Top