customerio v0.2.1 Customerio

Main module to interact with API.

Link to this section Summary

Types

Represents the type of an Customer.IO API answers

Represents fuzzy type that can be used to send data to Customer.IO

Functions

Add the list of customer ids to the specified manual segment. If you send customer ids that don't exist yet in an add_to_segment request, we will automatically create customer profiles for the new customer ids

Add the list of customer ids to the specified manual segment. If you send customer ids that don't exist yet in an add_to_segment request, we will automatically create customer profiles for the new customer ids

Track anonymous events directly without customer ID

Track anonymous events directly without customer ID

Delete customers

Delete customers

Delete a customer device

Creating or updating customers

Creating or updating customers

Remove the list of customer ids from the specified manual segment

Remove the list of customer ids from the specified manual segment

Deletes the customer with the provided id if it exists and suppresses all future events and identifies for for that customer

Deletes the customer with the provided id if it exists and suppresses all future events and identifies for for that customer

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

Start tracking events and identifies again for a previously suppressed customer. Note when a user is suppressed thier history is deleted and unsupressing them wil not recover that history

Start tracking events and identifies again for a previously suppressed customer. Note when a user is suppressed thier history is deleted and unsupressing them wil not recover that history

Link to this section Types

Link to this type

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

Represents the type of an Customer.IO API answers

Link to this type

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

Represents fuzzy type that can be used to send data to Customer.IO

Link to this section Functions

Link to this function

add_device(id, device_id, platfrom, data_map \\ %{}, opts \\ [])
add_device(
  id :: value(),
  device_id :: value(),
  platform :: value(),
  data_map :: map(),
  opts :: Keyword.t()
) :: {:ok, result()} | {:error, Customerio.Error.t()}

Create or update a customer device.

Params

  • id - the unique identifier for the customer.

  • device_id - The unique token for the user device.

  • platform - The platform for the user device. Allowed values are 'ios' and 'android'.

  • data_map - custom attributes to define the request:

    • last_used - UNIX timestamp representing the last used time for the device. If this is not included we default to the time of the device identify.
  • opts - HTTPoison options.

Example

iex> Customerio.add_device(5, "my_ios_device_id", "ios", %{last_used: 1514764800})
{:ok, "..."}
iex> Customerio.add_device(5, "my_ios_device_id", "epic_fail_devise")
{:error, %Customerio.Error{}}
Link to this function

add_device!(id, device_id, platfrom, data_map \\ %{}, opts \\ [])
add_device!(
  id :: value(),
  device_id :: value(),
  platform :: value(),
  data_map :: map(),
  opts :: Keyword.t()
) :: result() | no_return()

Create or update a customer device.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • device_id - The unique token for the user device.

  • platform - The platform for the user device. Allowed values are 'ios' and 'android'.

  • data_map - custom attributes to define the request:

    • last_used - UNIX timestamp representing the last used time for the device. If this is not included we default to the time of the device identify.
  • opts - HTTPoison options.

Example

iex> Customerio.add_device(5, "my_ios_device_id", "ios", %{last_used: 1514764800})
"..."
iex> Customerio.add_device(5, "my_ios_device_id", "epic_fail_devise")
** (Customerio.Error) "Epic fail!"
Link to this function

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

Add the list of customer ids to the specified manual segment. If you send customer ids that don't exist yet in an add_to_segment request, we will automatically create customer profiles for the new customer ids.

Params

  • id - the unique identifier of the segment.

  • ids - a list of customer ids to add to the segment.

  • opts - HTTPoison options.

Example

iex> Customerio.add_to_segment(1, [1, 2, 3])
{:ok, "..."}
iex> Customerio.add_to_segment(1000, [1, 2, 3])
{:error, %Customerio.Error{}}
Link to this function

add_to_segment!(id, ids, opts \\ [])
add_to_segment!(id :: value(), ids :: [value()], opts :: Keyword.t()) ::
  result() | no_return()

Add the list of customer ids to the specified manual segment. If you send customer ids that don't exist yet in an add_to_segment request, we will automatically create customer profiles for the new customer ids.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier of the segment.

  • ids - a list of customer ids to add to the segment.

  • opts - HTTPoison options.

Example

iex> Customerio.add_to_segment!(1, [1, 2, 3])
"..."
iex> Customerio.add_to_segment(1000, [1, 2, 3])
** (Customerio.Error) "Epic fail!"
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"})
{:ok, "..."}
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"})
"..."
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 :: Keyword.t()) :: 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

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

Delete a customer device.

Params

  • id - the unique identifier for the customer.

  • device_id - the unique token for the user device.

  • opts - HTTPoison options.

Example

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

delete_device!(id, device_id, opts \\ [])
delete_device!(id :: value(), device_id :: value(), opts :: Keyword.t()) ::
  result() | no_return()

Delete a customer device.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • device_id - the unique token for the user device.

  • opts - HTTPoison options.

Example

iex> Customerio.delete_device!(5, :my_device)
"..."
iex> Customerio.delete_device!(6, :fail_device)
** (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 :: Keyword.t()) ::
  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

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

Remove the list of customer ids from the specified manual segment.

Params

  • id - the unique identifier of the segment.

  • ids - a list of customer ids to add to the segment.

  • opts - HTTPoison options.

Example

iex> Customerio.remove_from_segment(1, [1, 2, 3])
{:ok, "..."}
iex> Customerio.remove_from_segment(1000, [1, 2, 3])
{:error, %Customerio.Error{}}
Link to this function

remove_from_segment!(id, ids, opts \\ [])
remove_from_segment!(id :: value(), ids :: [value()], opts :: Keyword.t()) ::
  result() | no_return()

Remove the list of customer ids from the specified manual segment.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier of the segment.

  • ids - a list of customer ids to add to the segment.

  • opts - HTTPoison options.

Example

iex> Customerio.remove_from_segment!(1, [1, 2, 3])
"..."
iex> Customerio.remove_from_segment(1000, [1, 2, 3])
** (Customerio.Error) "Epic fail!"
Link to this function

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

Deletes the customer with the provided id if it exists and suppresses all future events and identifies for for that customer.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

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

suppress!(id, opts \\ [])
suppress!(id :: value(), opts :: Keyword.t()) :: result() | no_return()

Deletes the customer with the provided id if it exists and suppresses all future events and identifies for for that customer.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

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

track(id, name, data_map, opts \\ [])
track(
  id :: value(),
  name :: value(),
  data_map :: %{key: value()},
  opts :: Keyword.t()
) :: {: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})
"..."
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, "..."}
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"})
"..."
iex> Customerio.track_page_view!(5, "http://google.com", %{ref: "fail"})
** (Customerio.Error) "Epic fail!"
Link to this function

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

Start tracking events and identifies again for a previously suppressed customer. Note when a user is suppressed thier history is deleted and unsupressing them wil not recover that history.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

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

unsuppress!(id, opts \\ [])
unsuppress!(id :: value(), opts :: Keyword.t()) :: result() | no_return()

Start tracking events and identifies again for a previously suppressed customer. Note when a user is suppressed thier history is deleted and unsupressing them wil not recover that history.

Raises Customerio.Error if fails.

Params

  • id - the unique identifier for the customer.

  • opts - HTTPoison options.

Example

iex> Customerio.unsuppress!(5)
"..."
iex> Customerio.unsuppress!(6)
** (Customerio.Error) "Epic fail!"