Reputation: 640
I implement Firebase Analytics for my iOS app and i have set IS_ANALYTICS_ENABLED in GoogleServicec-info.plist,
I tried to log 3 different event to test Firebase analytics
FIRAnalytics.logEventWithName("tap_cart", parameters: ["userId":userId,"productId":productId] )
FIRAnalytics.logEventWithName("tapCart", parameters: [kFIRParameterItemID:productId,kFIRParameterContentType: username, "userId":userId, kFIRParameterValue: productName])
FIRAnalytics.logEventWithName("tap_buy", parameters: [kFIRParameterContentType: username,kFIRParameterItemID: productId])
after wait for several hours (maybe 3-4 hours), my Firebase console show those event (tap_cart, tapCart, and tap_buy), but none of those show the parameters when i go to it`s detail.
My expected result is like this image
i want to see the chart based based on my user and product which he/she tap to buy, what i`m missing here?
Upvotes: 0
Views: 4046
Reputation: 3952
The first thing I would do is enable Firebase debug mode so you can see what is being sent. Here's how:
First. There is no reason to enable IS_ANALYTICS_ENALBED. As poorly named as it is this actually enables Google Analytics... which is more web oriented wherein firebase is more mobile + the kitchen sink oriented.
Second: Before sending any events do this:
FIRAnalytics.setUserID([your userId here)
<-- now all subsequent events are identifiable by userId
Now let's look at what's up with your events:
FIRAnalytics.logEventWithName("tap_cart", parameters: ["userId":userId,"productId":productId] )
This event has two custom parameters (userId / productId). Custom parameters aren't used for sexy reports, mainly for drill down filtering. Per the Firebase docs:
Custom parameters: Although these custom parameters are not represented directly in your Analytics reports, they can be used as filters in audience definitions that can be applied to every report
FIRAnalytics.logEventWithName("tapCart", parameters: [kFIRParameterItemID:productId,kFIRParameterContentType: username, "userId":userId, kFIRParameterValue: productName])
The firebase constant parameters you have used are not designed for a custom event such as "tapCart". Instead try the constant event that they provided for just this type of occurrence: kFIREventAddToCart
. But even then, I see some issues with your chosen parameters:
kFIRParameterItemID
- make sure you send this as type NSStringkFIRParameterContentType
is not a param of kFIREventAddToCart. Your "username" will be passed with each event now anyway because of our prior setUserId. Remove this param!kFIRParameterValue
is not for a productName. This value incrementally adds it's value to every event you fire of this type. It's a way to have firebase keep track of things like quantity ordered, revenue earned, times apologized to wife for not getting off computer, etc. You can use it in this instance but note it will add together the sum total of ALL items you have entered in your shopping cart. Please also note that if you DO choose to use this parameter you must also use the kFIRParameterCurrency
currency parameterkFIRParameterItemName}
FIRAnalytics.logEventWithName("tap_buy", parameters: [kFIRParameterContentType: username,kFIRParameterItemID: productId])
As you might be guessing by now, this has some similiar issues, such as:
kFIRParameterContentType
is not a parameter for kFIREventAddToCart
. Instead useSide note: you are also using kFIRParameterValue parameter wrong. This parameter is used for accumulating values of an event over time (distance, revenue, logins, days without sex, etc). The declaration (cmd+click) of kFIRParameterValue parameter states:
This is a general purpose parameter that is useful for accumulating a key metric that pertains to an event. Examples include revenue, distance, time and points. Value should be specified as signed 64-bit integer or double as NSNumber.
Upvotes: 5