Sending events in Leanbase
Once your Leanbase instance is set up and running, the next step is to start sending events from your app.
Leanbase supports event tracking across multiple platforms:
Setting event properties
Optionally, you can include additional information with the event by including a properties object:
Capturing pageviews
Event ingestion
t's a priority for us that events are fully processed and saved as soon as possible. Typically, events will be usable in queries within a few minutes.
Advanced: Anonymous vs identified events
Leanbase captures two types of events: anonymous and identified
Identified events enable you to attribute events to specific users, and attach person properties. They're best suited for logged-in users.
Scenarios where you want to capture identified events are:
Tracking logged-in users in B2B and B2C SaaS apps
Doing user segmented product analysis
Growth and marketing teams wanting to analyze the complete conversion lifecycle
Anonymous events are events without individually identifiable data. They're best suited for web analytics or apps where users aren't logged in.
Scenarios where you want to capture anonymous events are:
Tracking a marketing website
Content-focused sites
B2C apps where users don't sign up or log in
Under the hood, the key difference between identified and anonymous events is that for identified events we create a person profile for the user, whereas for anonymous events we do not.
How to capture anonymous events
Web
The JavaScript Web SDK captures anonymous events by default. However, this may change depending on your person_profiles config when initializing LeanBase:
person_profiles: 'identified_only' (recommended) (default) - Anonymous events are captured by default. Leanbase only captures identified events for users where person profiles have already been created.
person_profiles: 'always' - Capture identified events for all events.
For example:
Backend
PostHog's backend SDKs and API capture identified events by default. To capture anonymous events, set the $process_person_profile property to false:
Android
The Android SDK captures anonymous events by default. However, this may change depending on your personProfiles config when initializing PostHog:
personProfiles = PersonProfiles.IDENTIFIED_ONLY (recommended) (default) - Anonymous events are captured by default. PostHog only captures identified events for users where person profiles have already been created.
personProfiles = PersonProfiles.ALWAYS - Capture identified events for all events.
personProfiles = PersonProfiles.NEVER - Capture anonymous events for all events.
For example:
iOS
The iOS SDK captures anonymous events by default. However, this may change depending on your personProfiles config when initializing Leanbase:
personProfiles: .identifiedOnly (recommended) (default) - Anonymous events are captured by default. Leanbase only captures identified events for users where person profiles have already been created.
personProfiles: .always - Capture identified events for all events.
personProfiles: .never - Capture anonymous events for all events.
For example:
Flutter
The Flutter SDK captures anonymous events by default. However, this may change depending on your personProfiles config when initializing Leanbase:
personProfiles: LeanbasePersonProfiles.identifiedOnly (recommended) (default) - Anonymous events are captured by default. Leanbase only captures identified events for users where person profiles have already been created.
personProfiles: LeanbasePersonProfiles.always - Capture identified events for all events.
personProfiles: LeanbasePersonProfiles.never - Capture anonymous events for all events.
For example:
How to capture identified events
Web
If you've set the personProfiles config to IDENTIFIED_ONLY (the default option), anonymous events are captured by default. To capture identified events, call any of the following functions:
When you call any of these functions, it creates a person profile for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
Alternatively, you can set personProfiles to ALWAYS to capture identified events by default.
Backend
PostHog's backend SDKs and API capture identified events by default.
Android
If you've set the personProfiles config to IDENTIFIED_ONLY (the default option), anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
identify()
alias()
group()
When you call any of these functions, it creates a person profile for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
Alternatively, you can set personProfiles to ALWAYS to capture identified events by default.
iOS
If you've set the personProfiles config to IDENTIFIED_ONLY (the default option), anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
identify()
alias()
group()
When you call any of these functions, it creates a person profile for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
Alternatively, you can set personProfiles to ALWAYS to capture identified events by default.
Flutter
If you've set the personProfiles config to IDENTIFIED_ONLY (the default option), anonymous events are captured by default. Then, to capture identified events, call any of the following functions:
identify()
alias()
group()
When you call any of these functions, it creates a person profile for the user. Once this profile is created, all subsequent events for this user will be captured as identified events.
Alternatively, you can set personProfiles to ALWAYS to capture identified events by default.