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.
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)
}
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")
so for example I ould have:
//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.