Elixir
Send vTilt events from any Elixir code by POSTing to the ingest API. Compatible with Phoenix, OTP releases, and stand-alone scripts.
There's no native Elixir SDK yet, but vTilt's wire format is a plain JSON POST so any Elixir code can emit events. Use this guide for non-Phoenix Elixir projects (OTP releases, scripts, Broadway pipelines). For Phoenix, see the dedicated Phoenix guide.
#1. Add dependencies
# mix.exs
defp deps do
[
{:req, "~> 0.5"},
{:jason, "~> 1.4"},
]
endelixir
# config/runtime.exs
config :my_app, :vtilt,
token: System.fetch_env!("VTILT_TOKEN"),
host: System.get_env("VTILT_HOST") || "https://www.vtilt.com"elixir
#2. Capture module
# lib/my_app/vtilt.ex
defmodule MyApp.VTilt do
require Logger
@spec capture(String.t(), String.t(), map()) :: :ok
def capture(distinct_id, event, properties \\ %{}) do
cfg = Application.get_env(:my_app, :vtilt)
Task.start(fn ->
result = Req.post(
cfg[:host] <> "/api/e",
json: %{
api_key: cfg[:token],
event: event,
distinct_id: distinct_id,
properties: properties
},
receive_timeout: 2_000
)
case result do
{:ok, _} -> :ok
{:error, e} -> Logger.warning("vtilt capture failed: #{inspect(e)}")
end
end)
:ok
end
def identify(distinct_id, properties) do
capture(distinct_id, "$identify", %{"$set" => properties})
end
endelixir
#3. Capture events
MyApp.VTilt.identify("user_42", %{email: "alice@example.com", plan: "pro"})
MyApp.VTilt.capture("user_42", "purchase_completed", %{amount: 99.99, currency: "USD"})elixir
#4. Broadway pipeline (recommended)
For high-throughput pipelines, batch captures through a Broadway producer to avoid hammering vTilt with individual requests.
defmodule MyApp.VTiltPipeline do
use Broadway
def handle_message(_, %Broadway.Message{data: {distinct_id, event, props}} = msg, _ctx) do
MyApp.VTilt.capture(distinct_id, event, props)
msg
end
endelixir
#Next steps
- Phoenix integration guide — Phoenix-specific helpers + LiveView bridge.
- Identify & alias — full identification model.
- Event forwarding — fan events out to GA4, Meta CAPI, PostHog.