# `PostHog.Integrations.Plug`
[🔗](https://github.com/posthog/posthog-elixir/blob/v2.18.0/lib/posthog/integrations/plug.ex#L1)

Provides a plug that automatically extracts and sets relevant metadata from
`Plug.Conn`.

For Phoenix apps, add it to your `endpoint.ex` somewhere before your router:

    plug PostHog.Integrations.Plug
    
For Plug apps, add it directly to your router:

    defmodule MyRouterPlug do
      use Plug.Router
      
      plug PostHog.Integrations.Plug
      plug :match
      plug :dispatch
      
      ...
    end

---

*Consult [api-reference.md](api-reference.md) for complete listing*
