hectorperez / amplitude_ex

An Elixir client for the Amplitude HTTP API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Amplitude_ex

An Elixir client for the Amplitude HTTP API

Installation

  1. Add amplitude to your list of dependencies in mix.exs:
def deps do
  [{:amplitude, "~> 0.3.0"}]
end
  1. Set your api_key in config.exs, for example from an enviroment variable:
config :amplitude,
  api_key: System.get_env("MY_AMPLITUDE_KEY")

Testing

Add this to test.exs so it doesn't make api requests in test enviroment:

  config :amplitude,
    track_api_url: "test",
    identify_api_url: "test"

Usage

  1. Track events with the Amplitude.track/4 function:
iex> Amplitude.track("LOGIN_SUCCESS", "janedoe_123", %{"ip" => "127.0.0.1"}, %{"cohort" => "Test A"}, api_key: "<your_api_key>")
{:ok, "success"}

See Amplitude track event parameters for more details on supported params to track.

  1. Identify users with the Amplitude.identify/3 function:
iex> Amplitude.identify("janedoe_123", %{"gender" =>"female"}, %{"country" => "Canada"}, api_key: "<your_api_key>")
{:ok, "success"}

See Amplitude identify parameters

About

An Elixir client for the Amplitude HTTP API

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Elixir 100.0%