Firebase analytics parameter tracking

Is anyone here using Firebase for analytics?

Using this code:

firebase.analytics.log_string(name, parameter_name, parameter_value)

Seems to mean that to access parameter_value in Firebase it has to be registered as a “Parameter”. Each app can register a maximum of 10 parameters per type (int, string etc).

This seems quite limiting, and I wondered if there is another way of tracking only one value? For example “score”.

There is a bunch of predefined events that can be used:

One of which is “post_score”:

We should probably expose these predefined event constants: firebase.EVENT_POST_SCORE or something like that

3 Likes

Wow, completely missed these. Thanks so much, that makes a big difference.

And we already had a ticket for this:

@totebo feel free to contribute this if you have the time! I’ve started in the dev-event-names branch:

1 Like

Practically, how would these be used with Defold? Take kEventPostScore, for instance, would I use firebase.log_table() to log the event, something like this?

local name = "post_score"
local parameters_table = {}
parameters_table. score = 123
parameters_table. level = 1
parameters_table.character = "no_revive"
firebase.analytics.log_table(name, parameters_table)

If so, would log_table() be used even for events with just one parameter, like this?

local name = "level_start"
local parameters_table = { level_name="grasslands" }
firebase.analytics.log_table(name, parameters_table)

I assume I’d use firebase.log() for events without any parameters, like kEventLevelEnd?

If I do get some time I may look at it. Although I may break everything.

Good point. The documentation for the “post_score” event mentions that it takes three parameters: score, level and character. The parameters are defined in parameter_names.h and they should have corresponding constants in the extension. I added the first three to the branch:

firebase.analytics.PARAM_SCORE
firebase.analytics.PARAM_LEVEL
firebase.analytics.PARAM_CHARACTER

And yes, you would use them like in your example, in a table:

local fa = firebase.analytics

local event = {
	[fa.PARAM_SCORE] = 123,
	[fa.PARAM_LEVEL] = 1,
	[fa.PARAM_CHARACTER] = "no_revive",
}
fa.log_table(fa.EVENT_POST_SCORE, event)
1 Like

Added the predefined event and parameter constants:

2 Likes