Amplitude_ex
An Elixir client for the Amplitude HTTP API
Installation
If available in Hex, the package can be installed as:
- Add
amplitude
to your list of dependencies inmix.exs
:
def deps do
[{:amplitude, "~> 0.2.0"}]
end
- Ensure
amplitude
is started before your application:
def application do
[applications: [:amplitude]]
end
- Add an Amplitude API key to your application config file:
config :amplitude, api_key: "<your_api_key>"
Usage
- Track events with the
Amplitude.track/4
function:
iex> Amplitude.track("LOGIN_SUCCESS", "janedoe_123", %{"ip" => "127.0.0.1"}, %{"cohort" => "Test A"})
{:ok, "success"}
See Amplitude track event parameters for more details on supported params to track.
- Identify users with the
Amplitude.identify/3
function:
iex> Amplitude.identify("janedoe_123", %{"gender" =>"female"}, %{"country" => "Canada"})
{:ok, "success"}