Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Analytics VIEW_ITEM_LIST ITEMS not showing

I am trying to report a VIEW_ITEM_LIST event with some ITEMS inside. Everything is reported properly in the Debug View except for the items. I am not using any custom event. It seems to happen the same problem in both Android and iOS.

Here is my code.

 override fun trackListViewEvent() {
    val eventBundle = Bundle().apply {
        val itemBundle1 = Bundle().apply {
            putString(Param.ITEM_NAME, "name1")
            putString(Param.ITEM_CATEGORY, "Category")
            putString(Param.PRICE, "49.95")
            putString(Param.CURRENCY, "EUR")
        }

        val itemBundle2 = Bundle().apply {
            putString(Param.ITEM_NAME, "name2")
            putString(Param.ITEM_CATEGORY, "Category")
            putString(Param.PRICE, "89.95")
            putString(Param.CURRENCY, "EUR")
        }
            putString(Param.ITEM_LIST_ID, "1234567890")
            putString(Param.ITEM_LIST_NAME, "WhateverListName")
            putString(Param.PRICE, "125.60")
            putString(Param.CURRENCY, "EUR")

            putParcelableArray(Param.ITEMS, arrayOf(itemBundle1, itemBundle2))
        }
    tracking.logEvent(Event.VIEW_ITEM_LIST, eventBundle)
}

In the Logcat I get: W/FA-SVC: Param value can't be null: items

Another problem is that it seems that ITEMS only accepts some parameters. When adding custom parameters I get E/FA: Item cannot contain custom parameters, but when adding NOT custom parameters like FLIGHT_NUMBER I get the same error. And I could not find any explanation on the documentation on which parameters are accepted.

like image 904
Nil Oleart Avatar asked Apr 16 '20 12:04

Nil Oleart


People also ask

How long does it take for Firebase Analytics to update?

Firebase says that it can take up to 24h hours, but the docs say that the dashboard updates "a few times every day".

How long does it take for Firebase events to appear?

Generally, events logged by your app are batched together over the period of approximately one hour and uploaded together.

How do I see all devices in Firebase Analytics?

You can see the device list in Firebase Analytics. In dashboard -> device model click in view device model. You can see list of all the devices with details.

How do I know if Firebase Analytics is working?

In the Firebase console, open your project. Select Analytics from the menu to view the Analytics reporting dashboard. The Events tab shows the event reports that are automatically created for each distinct type of event logged by your app.


2 Answers

The example code from Google (link) written in Java, converts to this code in Kotlin

val item1 = Bundle()
item1.putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings")
item1.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants")
val item2 = Bundle()
item2.putString(FirebaseAnalytics.Param.ITEM_NAME, "boots")
item2.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "shoes")

parameters.putParcelableArray(FirebaseAnalytics.Param.ITEMS, arrayOf(item1, item2))

This does not work: on Emulator I got firebase error 25 and on a device it did not show at all in DebugView). You have to infer the Parcelable. So change the last line to below and you should be fine!

parameters.putParcelableArray(FirebaseAnalytics.Param.ITEMS, arrayOf<Parcelable>(item1, item2))
like image 68
Raz Avatar answered Oct 17 '22 06:10

Raz


I've been working on this for some months so I can shed some light in case anyone is having similar problems:

  1. Items are not shown in the debug view but they arrive correctly at GTM (if there is not any problem)
  2. About errors: firebase updated its errors and now error 23 (and some more) appears.
  3. Enhanced ecommerce does not accept custom parameters and there is not a list of accepted parameters, so follow the documentation to see what parameters can be used.
  4. To put a list of items in a bundle use:

Bundle().apply{ putParcelabelArray(Param.ITEMS, bundleList.toTypedArray()}

During this months some parameters and events have been deprecated. So you should constantly check if there are any changes. Keep in mind that firebase analytics for web + app will be released soon, maybe it's a good idea implementing directly web + app.

like image 30
Nil Oleart Avatar answered Oct 17 '22 06:10

Nil Oleart