customerio v0.2.0 Customerio

Main module to interact with API.

Link to this section Summary

Functions

Track anonymous events directly without customer ID

Track anonymous events directly without customer ID

Delete customers

Delete customers

Creating or updating customers

Creating or updating customers

Track the event for given customer

Track the event for given customer

Track page view event directly with customer ID

Track page view event directly with customer ID

Link to this section Types

Link to this type

result()
result() :: String.t()

Link to this type

value()
value() :: number() | String.t() | atom()

Link to this section Functions

Link to this function

anonymous_track(name, data_map, opts \\ [])
anonymous_track(
  name :: value(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: {:ok, result()} | {:error, Customerio.Error.t()}

Track anonymous events directly without customer ID.

Params

  • name - the name of the event to track.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.anonymous_track("purchase", %{recipient: "success@example.com"})
"..."
iex> Customerio.anonymous_track("purchase", %{recipient: "fail@example.com"})
{:error, %Customerio.Error{}}
Link to this function

anonymous_track!(name, data_map, opts \\ [])
anonymous_track!(
  name :: value(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: result() | no_return()

Track anonymous events directly without customer ID.

Raises Customerio.Error if fails.

Params

  • name - the name of the event to track.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.anonymous_track!("purchase", %{recipient: "success@example.com"})
%Customerio.Success{}
iex> Customerio.anonymous_track!("purchase", %{recipient: "fail@example.com"})
** (Customerio.Error) "Epic fail!"
Link to this function

delete(id, opts \\ [])
delete(id :: value(), opts :: [{:key, value()}]) ::
  {:ok, result()} | {:error, Customerio.Error.t()}

Delete customers.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.delete(5)
{:ok, "..."}
iex> Customerio.delete(6)
{:error, %Customerio.Error{}}
Link to this function

delete!(id, opts \\ [])
delete!(id :: value(), opts :: [{:key, value()}]) :: result() | no_return()

Delete customers.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.delete!(5)
",,,"
iex> Customerio.delete!(6)
** (Customerio.Error) "Epic fail!"
Link to this function

identify(id, data_map, opts \\ [])
identify(id :: value(), data_map :: %{key: value()}, opts :: [{:key, value()}]) ::
  {:ok, result()} | {:error, Customerio.Error.t()}

Creating or updating customers.

Params

  • id - the unique identifier for the customer.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.identify(5, %{email: "success@example.com"})
{:ok, "..."}
iex> Customerio.identify(6, %{email: "fail@example.com"})
{:error, %Customerio.Error{}}
Link to this function

identify!(id, data_map, opts \\ [])
identify!(id :: value(), data_map :: %{key: value()}, opts :: [{:key, value()}]) ::
  result() | no_return()

Creating or updating customers.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.identify!(5, %{email: "success@example.com"})
".."
iex> Customerio.identify!(6, %{email: "fail@example.com"})
** (Customerio.Error) "Epic fail!"
Link to this function

track(id, name, data_map, opts \\ [])
track(
  id :: value(),
  name :: value(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: {:ok, result()} | {:error, Customerio.Error.t()}

Track the event for given customer.

Params

  • id - the unique identifier for the customer.

  • name - the name of the event to track.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.track(5, "purchase", %{price: 23,45})
{:ok, "..."}
iex> Customerio.track(6, "crash", %{reason: "epic fail"})
{:error, %Customerio.Error{}}
Link to this function

track!(id, name, data_map, opts \\ [])
track!(
  id :: value(),
  name :: value(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: result() | no_return()

Track the event for given customer.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • name - the name of the event to track.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.track!(5, "purchase", %{price: 23,45})
%Customerio.Success{}
iex> Customerio.track!(6, "crash", %{reason: "epic fail"})
** (Customerio.Error) "Epic fail!"
Link to this function

track_page_view(id, page_name, data_map, opts \\ [])
track_page_view(
  id :: value(),
  page_name :: String.t(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: {:ok, result()} | {:error, Customerio.Error.t()}

Track page view event directly with customer ID.

Params

  • id - the unique identifier for the customer.

  • page_name - the URL of the page.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.track_page_view(5, "http://google.com", %{ref: "success"})
{:ok, %Customerio.Success{}}
iex> Customerio.track_page_view(5, "http://google.com", %{ref: "fail"})
{:error, %Customerio.Error{}}
Link to this function

track_page_view!(id, page_name, data_map, opts \\ [])
track_page_view!(
  id :: value(),
  page_name :: value(),
  data_map :: %{key: value()},
  opts :: [{:key, value()}]
) :: result() | no_return()

Track page view event directly with customer ID.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • page_name - the URL of the page.

  • data_map - custom attributes to define the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.track_page_view!(5, "http://google.com", %{ref: "success"})
%Customerio.Success{}
iex> Customerio.track_page_view!(5, "http://google.com", %{ref: "fail"})
** (Customerio.Error) "Epic fail!"