Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Use cloudflare header for fingerprint

Uku Taht759c21fff07f
diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex
index 616feccb01..fc00b056b3 100644
--- a/lib/plausible_web/controllers/api/external_controller.ex
+++ b/lib/plausible_web/controllers/api/external_controller.ex
@@ -79,7 +79,7 @@ defmodule PlausibleWeb.Api.ExternalController do
defp calculate_raw_fingerprint(conn, params) do
user_agent = List.first(Plug.Conn.get_req_header(conn, "user-agent")) || ""
- ip_address = to_string(:inet_parse.ntoa(conn.remote_ip)) || ""
+ ip_address = List.first(Plug.Conn.get_req_header(conn, "cf-connecting-ip")) || ""
domain = strip_www(params["domain"]) || ""
Enum.join([user_agent, ip_address, domain], ":")
end