0

In my A/B testing (with Remote Configs), I want to know which variant performed better based on daily user engagement.

As I can not see the built-in goal metric "Daily user engagement" in the dashboard, so I want to create my custom.

Could I track an event with parameter VALUE and set it as a goal metric (based on its value) in A/B testing? This is how want to do:

// Firebase Unity SDK
FirebaseAnalytics.LogEvent("time_spent", FirebaseAnalytics.ParameterValue, time_spent_in_seconds);

Thank you.

1 Answers1

0

Declare an event in the class where you want the vent to be fired. I dont know the type of FirebaseAnalytics.ParameterValue as I am not familiar with firebase nor with your app. I will assume its a string:

public event EventHandler<string> raiseFirebaseEvent;

Wherever in your code (normally a different class where the event is declared, and after invoked which is the same) you need to add a listener to this event, this means to add a method to the event, to be called after in the event trigger.

In this other class you will have a method that will be the one to subscribe to the event:

prevate void FireBaseLogger(FirebaseAnalytics.ParameterValue value) {
    FirebaseAnalytics.LogEvent("time_spent", value, 
    time_spent_in_seconds);
} 

time_spent_in_seconds shoul be a variable of this other class I guess.

Somewhere in this class, usually in the constructor, or somewhere you know for sure that the code ejecution will go through there, you should subscribe to the event. For this you need a reference of your event holder class, where the event was declared:

EventHolderClassInstance.raiseFirebaseEvent += FireBaseLogger;

No arguments are passed in the subscription, just the method.

Then, in your EventHolderClass, when you invoke the event, passing the string parameter, the subscribed method will be called as long as the subscription was done prior the invocation.

raiseFirebaseEvent?.Invoke(this, FirebaseAnalytics.ParameterValue);

When there are no methods subscribed raiseFirebaseEvent is null, that is what the question mark is for. If there was no previous subscription raiseFirebaseEvent is null, and nothing happens.

In case FirebaseAnalytics.ParameterValueis not string type, change the type accordingly in the event and in the private method subscribed in the class where the listener is added, or where the subscription is made that means the same. Not sure if that is what you were asking.

rustyBucketBay
  • 4,320
  • 3
  • 17
  • 47