15

I have a game and I want to send event every time user sets new high score, I check if current score is > that previous and if it is I send that new high score to firebase. code:

Bundle bundle = new Bundle();
bundle.putLong(FirebaseAnalytics.Param.LEVEL, extras.getInt("score"));
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LEVEL_UP, bundle);

This is how it looks like in firebase console: image link

You can see how events are grouped by their value.

Problem is that i have 4 different modes and I want to capture high scores for each, so this is how I tried that:

Bundle bundle = new Bundle();
bundle.putLong(FirebaseAnalytics.Param.LEVEL, extras.getInt("score")); 
mFirebaseAnalytics.logEvent("mode4level", bundle);

And this is what I get in firebase console: image link

Grouped events by value are missing, I have only Event Location, Event demographics, Events per session.

How can I fix that, key part of analytics is missing ? Thank you.

Steve Haley
  • 55,374
  • 17
  • 77
  • 85
Alen
  • 949
  • 3
  • 17
  • 37

3 Answers3

7

Reporting on parameters is limited to a subset of suggested events such as the LEVEL_UP event you mentioned. You can find more information in this thread.

Technically, you could register a user property like "game_mode" and setting the value of this before you log LEVEL_UP. Then you could filter your LEVEL_UP event reporting using the filter game_mode=<mode>. We don't generally recommend doing this since user properties are meant to be used for attributes of your users that do not change often. However, it may suit your needs here.

Alternatively, you can just add a "game_mode" parameter to the LEVEL_UP event and then link your app to BigQuery to analyze your raw data to get a breakdown of levels per game mode.

Alwaysblue
  • 9,948
  • 38
  • 121
  • 210
Steve Ganem
  • 10,591
  • 2
  • 39
  • 32
  • I added user property "game_mode". Is this what my code should look like ? Bundle bundle = new Bundle(); bundle.putInt("game_mode", 1)); bundle.putLong(FirebaseAnalytics.Param.LEVEL, extras.getInt("score")); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LEVEL_UP, bundle); – Alen Jun 13 '16 at 09:07
  • 1
    no, setUserProperty( "game_mode", ); Then, register that user property in the User Properties tab of Firebase Analytics. – Steve Ganem Jun 13 '16 at 14:09
  • I registered user property "game_mode" in Firebase Analytics. Then i set value on that user property mode1/mode2/... Is this right code ? Bundle bundle = new Bundle(); mFirebaseAnalytics.setUserProperty( "game_mode", "mode1"); bundle.putLong(FirebaseAnalytics.Param.LEVEL,extras.getInt("score")); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LEVEL_UP, bundle); – Alen Jun 14 '16 at 09:19
  • Yes. That's right. Note that it's important to call setUserProperty before logEvent and you are doing that. – Steve Ganem Jun 14 '16 at 13:41
  • One more question: (I couldnt find answer). which dependencies should i include for firebase analytics. On firebase.google.com they say that 'com.google.firebase:firebase-core:9.0.2' should be included but in examples they use 'com.google.firebase:firebase-analytics:9.0.2' – Alen Jun 19 '16 at 09:01
  • Currently, there's no practical difference between core and analytics, but core may grow to include more than just analytics. You should add the core dependency. More info in this thread : http://stackoverflow.com/questions/37337834/what-the-difference-in-firebase-core-and-firebase-analytics-libraray – Steve Ganem Jun 19 '16 at 20:04
6

I have same problem, and after reading documentation I found this:

https://firebase.google.com/docs/analytics/android/events#log_events

Custom parameters: Custom parameters are not represented directly in your Analytics reports, but they can be used as filters in audience definitions that can be applied to every report. Custom parameters are also included in data exported to BigQuery if your app is linked to a BigQuery project.

msamardzic
  • 1,060
  • 9
  • 12
4

As of May 2017, custom parameter reporting is now supported in Google Analytics for Firebase. Please refer to this help center article for more details.