customerio v0.2.2 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
Create or update a customer device.
Create or update a customer device.
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.
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.
Trigger a campaign execution.
Trigger a campaign execution.
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
result()
result() :: String.t()
result() :: String.t()
Represents the type of an Customer.IO API answers
value()
Represents fuzzy type that can be used to send data to Customer.IO
Link to this section Functions
add_device(id, device_id, platfrom, data_map \\ %{}, opts \\ [])
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{}}
add_device!(id, device_id, platfrom, data_map \\ %{}, opts \\ [])
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!"
add_to_segment(id, ids, opts \\ [])
add_to_segment(id :: value(), ids :: [value()], opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
add_to_segment!(id, ids, opts \\ [])
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!"
anonymous_track(name, data_map, opts \\ [])
anonymous_track(
name :: value(),
data_map :: %{key: value()},
opts :: [{:key, value()}]
) :: {:ok, result()} | {:error, Customerio.Error.t()}
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{}}
anonymous_track!(name, data_map, opts \\ [])
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!"
delete(id, opts \\ [])
delete(id :: value(), opts :: [{:key, value()}]) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
delete!(id, opts \\ [])
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!"
delete_device(id, device_id, opts \\ [])
delete_device(id :: value(), device_id :: value(), opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
delete_device!(id, device_id, opts \\ [])
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!"
identify(id, data_map, opts \\ [])
identify(id :: value(), data_map :: %{key: value()}, opts :: [{:key, value()}]) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
identify!(id, data_map, opts \\ [])
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!"
remove_from_segment(id, ids, opts \\ [])
remove_from_segment(id :: value(), ids :: [value()], opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
remove_from_segment!(id, ids, opts \\ [])
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!"
suppress(id, opts \\ [])
suppress(id :: value(), opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
suppress!(id, opts \\ [])
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!"
track(id, name, data_map, opts \\ [])
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{}}
track!(id, name, data_map, opts \\ [])
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!"
track_page_view(id, page_name, data_map, opts \\ [])
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{}}
track_page_view!(id, page_name, data_map, opts \\ [])
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!"
trigger_campaign(id, data_map, opts \\ [])
trigger_campaign(id :: value(), data_map :: map(), opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
trigger_campaign(id :: value(), data_map :: map(), opts :: Keyword.t()) :: {:ok, result()} | {:error, Customerio.Error.t()}
Trigger a campaign execution.
Params
id
- the unique identifier of the campaign.data
- data to be included in the campaign.
Example
iex> Customerio.trigger_campaign(1, %{data: %{title: "hello"}})
{:ok, "{...}"}
iex> Customerio.trigger_campaign(666, %{data: %{title: "heaven company"}})
{:error, %Customerio.Error{}}
trigger_campaign!(id, data_map, opts \\ [])
Trigger a campaign execution.
Raises Customerio.Error
if fails.
Params
id
- the unique identifier of the campaign.data
- data to be included in the campaign.
Example
iex> Customerio.trigger_campaign(1, %{data: %{title: "hello"}})
{:ok, "{...}"}
iex> Customerio.trigger_campaign(666, %{data: %{title: "heaven company"}})
** (Customerio.Error) "Epic fail!"
unsuppress(id, opts \\ [])
unsuppress(id :: value(), opts :: Keyword.t()) ::
{:ok, result()} | {:error, Customerio.Error.t()}
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{}}
unsuppress!(id, opts \\ [])
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!"