1 Star 0 Fork 0

coolan2013/flutter-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Google Analytics

Steps for Analytics Integration :-

1) Setup your Flutter app in Firebase console.

2) Import Plugins in pubspec.yaml

a) firebase_analytics

b) firebase_core

3) Initialize FirebaseApp in main function

     void main() async {
     await Firebase.initializeApp();
     runApp(FlutterAnalyticsApp());
     }

4) Initialize FirebaseAnalytics and FirebaseAnalyticsObserver

    FirebaseAnalytics analytics = FirebaseAnalytics();
    FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics);

5) Setup observer to record navigation changes in app

   MaterialApp(
   -------------
     navigatorObservers: <NavigatorObserver>[observer],
     -------------
   );

6) Log Events (e.g.)

     await analytics.logEvent(
     name: 'item',
         parameters: <String, dynamic>{
           'price': price,
           'itemName': itemName,
           'quantity': quantity,
           'bool': addedToCart,
         },
     );

7) [Important] Enable debug mode to see events immediately

    As Events in Google/Firebase analytics takes around 24 hrs to reflect, so in order to test while developing make sure that you 
    run a debug build. Below is the link how you can do so.

Enable debug mode

Screenshots

.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/coolan2013/flutter-examples.git
git@gitee.com:coolan2013/flutter-examples.git
coolan2013
flutter-examples
flutter-examples
develop

搜索帮助