BentoSdk Stats API
Mix.install([
{:bento_sdk, "~> 0.1.0"}
])
Introduction
This notebook demonstrates how to use the BentoSdk to retrieve statistics from the Bento marketing platform. The Stats API allows you to:
- Get site statistics
- Get segment statistics
- Get report statistics
These statistics can help you understand the performance of your marketing efforts.
Configuration
We’ll use Livebook’s secrets feature to securely store and access your Bento credentials:
# Configure BentoSdk with the secrets
BentoSdk.configure(
site_uuid: System.fetch_env!("LB_BENTO_SITE_UUID"),
username: System.fetch_env!("LB_BENTO_USERNAME"),
password: System.fetch_env!("LB_BENTO_PASSWORD")
)
Getting Site Statistics
Let’s get overall site statistics:
# Example of getting site statistics
case BentoSdk.Stats.get_site() do
{:ok, stats} ->
stats
{:error, reason} ->
"Error: #{reason}"
end
Getting Segment Statistics
Let’s get statistics for a specific segment:
# Example of getting segment statistics
segment_id = "your_segment_id"
case BentoSdk.Stats.get_segment(segment_id) do
{:ok, stats} ->
stats
{:error, reason} ->
"Error: #{reason}"
end
Getting Report Statistics
Let’s get data for a specific report:
# Example of getting report statistics
report_id = "your_report_id"
case BentoSdk.Stats.get_report(report_id) do
{:ok, stats} ->
stats
{:error, reason} ->
"Error: #{reason}"
end