Skip to Content
ToolsAnalytics
Report an error
Open in ChatGPTOpen in Claude

Analytics

Understanding player behavior and server performance is key to growth.

Server Metrics

Key metrics to track for server health:

  • Concurrent Players: Peak times and retention.
  • Frame Time: Server performance latency (keep under 50ms).
  • Error Rate: Script errors per minute.
  • Economy Stats: Total cash flow, richest players.

GameEvents

FiveM provides the gameEventTriggered event which captures native game actions (damage, kills, vehicle entry).

AddEventHandler('gameEventTriggered', function(name, args) if name == 'CEventNetworkEntityDamage' then local victim = args[1] local attacker = args[2] local isFatal = args[6] == 1 if isFatal then print('Kill detected: ' .. victim .. ' killed by ' .. attacker) -- Send to analytics endpoint end end end)

Sentry (Error Tracking)

Sentry is excellent for tracking Lua errors in real-time.

  1. Create Project: Sign up at sentry.io  and create a “Node.js” or “Other” project.
  2. Install SDK: Use a resource like sentry-fivem or simple HTTP reporting.
  3. Global Error Handler:
-- Client-side error catching Citizen.CreateThread(function() local originalTrace = Citizen.Trace Citizen.Trace = function(data) if string.match(data, "Error") or string.match(data, "SCRIPT ERROR") then TriggerServerEvent('log:sentry', data) end originalTrace(data) end end)

Plausible (Web Analytics)

For your server’s website or Tebex store, Plausible provides privacy-friendly analytics.

  • Lightweight (< 1KB).
  • No cookies (GDPR compliant).
  • Track conversion rates for whitelist applications.

Custom Logging (Discord/Database)

For gameplay analytics (who robbed the bank, who sold drugs), log to a database or external API, NOT just Discord webhooks.

Why Database?

  • Searchable: SQL queries allow you to find patterns.
  • Retention: Discord limits message history searchability.
  • Visualization: Connect Grafana to your SQL DB to visualize economy inflation.
INSERT INTO analytics_events (event_type, player_id, metadata, created_at) VALUES ('robbery_start', 'char:123', '{"bank": "fleeca_01"}', NOW());

Best Practices

  • Don’t spam Discord: Webhooks have rate limits. Use a queue system or batch logs.
  • Anonymize Data: If sharing stats, hash IPs and identifiers.
  • Act on Insights: If analytics show 50% of players quit during the tutorial, fix the tutorial.