I developed a pixel tracking microservice using Elixir and Phoenix. I am trying to get the original URL where the pixel tracking is installed from Plug.Conn.
I assumed that I could try and get the Plug.Conn's HTTP_REFERRER header or variable or something but I must be wrong in maybe how the browser and HTTP works as I could not find anything about referrer in Plug.Conn in my controller.
Any ideas?
You can use get_req_header/2. For example
get_req_header(conn, "referer")
The referer is present in conn.req_headers. You can get it using List.keyfind/4:
case List.keyfind(conn.req_headers, "referer", 0) do
{"referer", referer} ->
IO.puts referer
nil ->
IO.puts "no referer"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With