Skip to content

Commit 72b8014

Browse files
unix14eyalYaakobi
authored andcommitted
add Funnels Manager example to readme file
Make analytics event more human-readable
1 parent b580927 commit 72b8014

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A Flutter library for custom analytics management, designed to streamline integr
66

77
- **Custom Event Tracking**: Easily log and manage events in your application.
88
- **Screen View Logging**: Track screen views to gain insights into user navigation.
9+
- ** **Funnels Manager**: Tracks the time it takes the users go through a journey in our app.
910
- **Robust Reporting**: Access detailed reports on user interactions and events.
1011

1112
## Getting Started
@@ -90,6 +91,34 @@ class _SimpleEventExampleScreenState extends State<SimpleEventExampleScreen> {
9091
}
9192
```
9293

94+
## Funnels Manager
95+
96+
### Purpose
97+
The `FunnelsManager` is a tool designed to track the sequence of user interactions or events in a specific flow, commonly referred to as a "funnel." A funnel is a defined series of steps that a user follows, and by tracking how users interact with these steps, you can gather insights on engagement, abandonment points, and overall user behavior.
98+
99+
### Implementation
100+
101+
1. **Create and Start a Funnel**
102+
To start tracking a funnel, you need to define a funnel using the `AnalytixFunnel` class and register it with the `FunnelsManager`. Here’s an example of how to start a funnel:
103+
104+
```dart
105+
FunnelsManager().start(AnalytixFunnel(Funnels.funnel_2, shouldCountTime: true));
106+
```
107+
• Funnels.funnel_2 is the name of the funnel you’re tracking.
108+
• The shouldCountTime flag tracks the time a user spends on each step of the funnel.
109+
2. **Tracking Events in the Funnel**
110+
After starting the funnel, you can track specific events or steps within the funnel. For example:
111+
```dart
112+
FunnelsManager().track(Funnels.funnel_3, "step_1");
113+
```
114+
This code logs the event "step_1" within the funnel_3.
115+
3. **Finishing a Funnel**
116+
Once the funnel is complete (i.e., when the user completes all the steps), make sure to finish the funnel to capture the final event and any time-related data:
117+
```dart
118+
FunnelsManager().finish(Funnels.funnel_2, "finish");
119+
```
120+
This marks the funnel as finished and logs the final event.
121+
93122
For help getting started with Flutter development, view the online
94123
[documentation](https://flutter.dev/).
95124

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
extension MapExtensions on Map<String, dynamic> {
3+
4+
String getString({bool isInner = false}) {
5+
String result = "";
6+
if(entries.isEmpty) {
7+
return "{}";
8+
}
9+
for(MapEntry<String, dynamic> keyValuePair in entries) {
10+
if(keyValuePair.value is Map<String, dynamic>) {
11+
result += "\n -> '${keyValuePair.key}' : ";
12+
// print inner map
13+
var innerMapString = (keyValuePair.value as Map<String, dynamic>).getString(isInner: true);
14+
result += innerMapString;
15+
} else {
16+
result += "\n ${isInner ? " " : ""}-> '${keyValuePair.key}': '${keyValuePair.value}'";
17+
}
18+
}
19+
return result;
20+
}
21+
}

lib/analitix/models/analytix_event.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
import 'package:analitix/analitix/extensions/map_extenions.dart';
3+
24
class AnalytixEvent {
35
final String eventName;
46
final String? subEventName;
@@ -8,6 +10,10 @@ class AnalytixEvent {
810

911
@override
1012
String toString() {
11-
return 'AnalytixEvent: $eventName, subEventName: $subEventName, parameters: $parameters';
13+
String result = 'AnalytixEvent: $eventName\nsubEventName: $subEventName';
14+
if(parameters?.isNotEmpty == true) {
15+
result += "\nparameters: ${parameters!.getString()}";
16+
}
17+
return result;
1218
}
1319
}

0 commit comments

Comments
 (0)