这是实施Firebase Analytics的正确有效的方法吗? [英] Is this a correct and efficient way to implement Firebase Analytics?

查看:73
本文介绍了这是实施Firebase Analytics的正确有效的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仔细阅读了文档和一些教程,但是我仍然不确定我了解代码的哪些部分是必要的,什么仅仅是示例. 由于分析不会立即更新,可能要花几天甚至更长的时间,因此我无法真正检查自己是否正确实施了该分析.如果有人可以告诉我我做对了,如果做对了,我做错了,我将不胜感激.

I went through the documentation and some tutorials, but I still don't feel confident that I understand what parts of the code are necessary and what are just an example. Because the analytics don't update immediately and could take a few days if not more then I can't really check if I am implementing it correctly. I would appreciate if someone could tell me if I'm doing it right and if not, what am I doing wrong.

我要在我的应用中跟踪大约10个动作. 我的应用程序中的所有片段都实现了特定的接口.在我的界面中,我创建了以下方法:

I have about 10 actions I want to track in my app. All the fragments in my app implement a certain interface. In my interface I've created the following method:

fun event(firebaseAnalytics : FirebaseAnalytics, name : String){
    val bundle = Bundle()
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name)
    firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)
}

在我的两个活动中,我都将firebaseAnalytics初始化为公共变量,如下所示:

at both my activities I've initialized firebaseAnalytics as as a public variable as follows:

firebaseAnalytics = FirebaseAnalytics.getInstance(this)

现在在片段中,每当我要跟踪的动作之一正在执行时,我都会像这样调用函数

Now in the fragments, whenever one of the actions I want to track is being executed, I call the function like this

event(firebaseAnalytics, "some_action_name_I_chose")

例如,我将拥有:

//when someone takes a photo
event(firebaseAnalytics, "photo_taken")

//when someone likes a photo
event(firebaseAnalytics, "photo_liked")

//when someone comments
event(firebaseAnalytics, "photo_commented")

这项工作吗?就这么简单吗?

Would this work? Is it as simple as that?

在文档中给出了以下代码:

In the documentation this code was given:

val bundle = Bundle()
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id)
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name)
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image")
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)

我不知道是否需要所有这些字段.商品编号?内容类型?还不是很清楚. 谢谢.

I can't understand if I need all these fields or not. Item id? content type? It's not very clear. Thanks.

推荐答案

为了测试您的分析是否通过服务器,不需要几天的时间. 您需要做的就是使您的应用程序进入后台并回到前台,并且应与服务器同步.

In order to test your analytics if it went up to the server or not, it does not take a few days. All you need to do is to make your app go to the background and back to the foreground and it should sync with the server.

您可以使用所需的任何信息记录事件,无需显示特定字段

You can log events with whatever info you want, there's no need for specific fields to be present

这篇关于这是实施Firebase Analytics的正确有效的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆