Firebase Analytics not showing screen names and events - android

I'm migrating from old google analytics to Firebase Analytics and now I'm tracking the screens using this:
mFirebaseAnalytics.setCurrentScreen(SectionManager.getInstance().getCurrentActivity(), name, null /* class override */);
And also tryed using this:
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
And I'm tracking events using this:
Bundle params = new Bundle();
params.putString("category", "command");
params.putString("action", "test command");
params.putString("label", "command test label");
mFirebaseAnalytics.logEvent("ga_event", params);
I'm testing the application openning some screens and passing it's name, and also I'm pressing some times a button which executes the event tracking code I showed.
The first problem is that in firebase panel, I can't find the "test command" event... Don't sure where should I find it, but I can't find it.
The second problem is that I can see the "screen class" of the activities I'm using for opening the screens, which represents the name of the activity, but the name of the screens I passed as a parameter to firebase is not present. If i filter to show the screen name I got this:
User engagement Screen name Screen name % total Avg. time
(not set) NaN - 0m 0s -100

If you're using the setCurrentScreen() event, you should be able to see it at the Analytics > Events panel. Then, select screen_view and a screen with, beyond other stuff, a card titled firebase_screen will show you the sceen_view events grouped by the name you gave them when logging the event.
Another card titled User engagement will show you the screen_class you want to see, as well as the visualization percentage and average time spent on each screen.
Custom events (like your ga_event) should also be shown at the Analytics > Events section at the Firebase Dashboard.
Important: Custom events might take up to 24 hours after called to show up on Firebase.

Related

Delay in Google OneTap SignIn / SignUp popup display on Android

I have implemented Google Onetap SignIn in my application. Everything is working fine, the only issue that I am observing is that on certain devices the pop-up often takes 7-10 seconds to display. Especially in case of Sign-In popup.
Since I have multiple login options available in the app it might so happen that before I can show the user his last used google account to login (via OneTap popup), he gets enough time to click on any other option (eg, Facebook) & it becomes a poor experience.
Since this pop-up is displayed by play-services, I don't see how I can optimise this time taken.
As per the code, it seems the call to
contract
.getOneTapClient()
.beginSignIn(getSignInRequest(isRegistering))
is the one taking the most time. It seems the code that queries for user's on device Google Accounts.
Using below code structure. Adding for reference
contract.getOneTapClient().beginSignIn(getSignInRequest(isRegistering))
.addOnSuccessListener { result: BeginSignInResult ->
try
{
contract.startIntentSenderForResult(
result.pendingIntent.intentSender, requestCode,
null, 0, 0, 0, null)
successCallback?.onSuccess(isRegistering, "Rendering Popup")
val timeTaken = if(isRegistering) System.currentTimeMillis() - signUpTime
else System.currentTimeMillis() - signInTime
BBLogUtils.logWithTag(TAG, "Completed in ${timeTaken/1000.0}s")
}
catch (e: IntentSender.SendIntentException)
{
failureCallback?.onFailure(isRegistering, e, ERROR_INTENT_SENDER_EXCEPTION)
}
}
.addOnFailureListener { e: Exception ->
// No saved credentials found.
// OR Temporarily blocked due to too many canceled sign-in prompts.
BBLogUtils.logWithTag(TAG, "Exception | registering=$isRegistering|rCount=$rCount | Error= ${e.message}")
failureCallback?.onFailure(isRegistering, e, ERROR_NO_CREDENTIALS_FOUND)
}
SignIn request object is the standard as prescribed by the docs
private fun getSignInRequest(isRegistering: Boolean): BeginSignInRequest
{
return BeginSignInRequest.builder()
.setGoogleIdTokenRequestOptions(BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
.setSupported(true) // So that we receive the idToken in result
.setServerClientId(contract.getGoogleAndroidClientId())
/*
* true: for Registration ie. showing all accounts
* false: for return user signIn, ie. showing only previously used accounts
**/
.setFilterByAuthorizedAccounts(!isRegistering)
.build())
.build()
}
Another related question to this feature.
On the first launch of the app on device I saw this additional pop-up
Is there someway this can be skipped ?
Answering 2nd part of my own query here.
After a lot search I still haven't bee able to find a workaround for skipping the process. Turns out that this popup is medium for play services to inform the user about the new sign-in experience.
I observed that if I installed another app using Google Onetap (eg. Reddit or PIntrest), the same pop-up appeared there as well. Also, its shown only once to a user, ie. if the pop up was shown in the Reddit app then it won't come in my app & vice-versa.
In addition, if you wan't to repro this scenario, you can clear the storage of Google Play Services. For some duration, it might show error: 16: App is not whitelisted, but after a while, you will get the How It Works pop-up again.

Firebase SDK Auth Package Trouble with Automatically Loading Scene Once Authenticated Unity

I am stuck with a functionality of the Firebase SDK (Auth package) regarding the Scenes and it's integration. Here's how they work:
1st: Loading Scene
Here, I just added the FirebaseInit code EXACTLY as suggested by Patrick, which it's only function is to call the next scene (Login/Register) once everything loads correctly.
2nd: Login/Register Scene
Here I do all the Login AND ALSO the register logic. I set up a button that alternates between the two (Activating the respective parent gameObject within the Canvas). Once the user log's in, the 3rd scene comes into play.
3rd: App's Main Screen Scene
Main Screen of the app, where the user can LOGOUT and return to the Login Scene.
Problem
I added the 'LoadSceneWhenUserAuthenticated.cs' in the 2nd Scene, and it works (kind of).
It actually does what it is supposed to. If I log in, quit the game without loging out, and open it again, it does come back directly to the 3rd scene. BUT some things are happening and they aren't supposed to.
First
When I Sign Up a user, I call the method 'CreateUserWithEmailAndPasswordAsync()'. Once it completes, it should activate the login screen and stay there, waiting for the user to fill in the password, but the 'FirebaseAuth.DefaultInstance.StateChanged' comes into play and forces the 3rd screen to be loaded, skipping several other steps that should be taken (email registration for example).
Second
As I mentioned in the end of number 1 above, if I try to log in to an account that does not have it's email verified, it works! (due to the 'LoadSceneWhenUserAuthenticated.cs' which is added in the scene). Code:
var LoginTask = auth.SignInWithEmailAndPasswordAsync(_email, _password);
LoginTask.ContinueWithOnMainThread(task =>
{
if (task.IsCanceled || task.IsFaulted)
{
Firebase.FirebaseException e =
task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;
GetErrorMessage((AuthError)e.ErrorCode, warningLoginText);
return;
}
if (task.IsCompleted)
{
User = LoginTask.Result;
if (User.IsEmailVerified == true)
{
UIControllerLogin.instance.MainScreenScene();
}
else
{
warningLoginText.text = Lean.Localization.LeanLocalization.GetTranslationText($"Login/VerifyEmail");
}
I know that it's possible to fix this issue by adding an extra scene just before the login scene (as Patrick does in the youtube video) but it doesn't make any sense in my app. It would actually only harm the UX of it.
Patrick's Video:
https://www.youtube.com/watch?v=52yUcKLMKX0&t=264s
I'm glad my video helped!
My architecture won't work for every game, and I tried to boil it down to the bare minimum to get folks started. You may be able to get the functionality you want by adding an additional check in HandleAuthStateChanged:
private void HandleAuthStateChanged(object sender, EventArgs e)
{
if (_auth.CurrentUser != null && !_auth.CurrentUser.IsAnonymous && _auth.CurrentUser.IsEmailVerified)
{
SceneManager.LoadScene(_sceneToLoad);
}
}
but it does sound like, at this point, you'll want to build out a more robust registration/sign in flow that fits your use case.
If you need more help, I might suggest re-posting on the community mailing list or the subreddit. Those resources may be more better suited to discussing various pros/cons of different architectures or spitballing ideas (and feel free to link to any new posts in a comment so myself or others interested can follow along).

Why reporting of custom events fails when I was conducting cross-platform data analysis using User-ID?

I have integrated the iOS SDK and Android SDK of HUAWEI Analytics Kit and plan to use User-ID to perform cross-platform and cross-device analysis to find out the lifecycle and behavior differences between iOS and Android users.
However, after I added a custom event for testing, the event is not displayed on the Real-time monitoring and App debugging pages. The code is as follows:
#Override
public void onClick(View v) {
for (int i = 0; i < 9; i++) {
// Set the custom event name to Purchase.
String eventId = "Purchase Test" + i;// DTM_Test
// Set parameters of the custom event.
Bundle bundle = new Bundle();
bundle.putDouble("price", 9.99 + i);
bundle.putLong("quantity", 100 + i);
bundle.putString("currency", "CNY");
// Trigger event reporting.
instance.onEvent(eventId, bundle);
}
In the code, eventId is Purchase Test, which contains a space character. This does not comply with the event ID definition rule. As a result, the event is filtered out.
Event ID definition rule of HUAWEI Analytics Kit: An event ID cannot be left empty or contain spaces. It can consist of a maximum of 256 characters including digits, letters, and underscores (_) but cannot start with a digit. In addition, its value cannot be the same as the ID of an automatically collected event.
Therefore, you can change Purchase Test to Purchase_Test or any other value that complies with the preceding rule.
If you have multiple iOS and Android apps in a project, you can use the filter to view the overall analysis report or detailed report of an app. You can even link users' activity data from different devices by using User-ID to obtain cross-platform analysis data. For details about cross-platform analysis.

OnProvideAssistDataListener example

Can someone please provide an example for a real case where I might need to use OnProvideAssistDataListener. I can't seem to wrap my head around it. I look at the source code, and then I look online. Someone online says
Application.OnProvideAssistDataListener allows to place into the
bundle anything you would like to appear in the
Intent.EXTRA_ASSIST_CONTEXT part of the assist Intent
I have also been reading through the Intent Docs.
There is an Now On Tap functionality implemented by Google. By long pressing the Home Button, you will get some  information displayed on the screen.  The information you get depends on what you're viewing on your screen at that time. (for eg: Music app displays information about music on the screen).
To provide additional information to the assistant, your app provides global application context by registering an app listener using registerOnProvideAssistDataListener() and supplies activity-specific information with activity callbacks by overriding onProvideAssistData() and onProvideAssistContent(). 
Now when the user activates the assistant, onProvideAssistData() is called to build a full ACTION_ASSIST Intent with all of the context of the current application represented as an instance of the AssistStructure. You can override this method to place anything you like into the bundle to appear in the EXTRA_ASSIST_CONTEXT part of the assist intent.
In the example below, a music app provides structured data to describe the music album that the user is currently viewing:
#Override
public void onProvideAssistContent(AssistContent assistContent) {
super.onProvideAssistContent(assistContent);
String structuredJson = new JSONObject()
.put("#type", "MusicRecording")
.put("#id", "https://example.com/music/recording")
.put("name", "Album Title")
.toString();
assistContent.setStructuredData(structuredJson);
}
For more info refer https://developer.android.com/training/articles/assistant.html

Where can i view the data sent by tracker on Google Analytics?

I have sent much data by Tracker to Google Analycis as following codes:
tracker= GoogleAnalytics.getInstance(this).getTracker("UA-46451607-1");
HashMap<String, String> hitParameters = new HashMap<String, String>();
hitParameters.put("type", "appview");
hitParameters.put("screen_name", "My Screen");
tracker.send(hitParameters);
After sent these data to platform,where can i see the result?
I would like to see the value of "type " and "screen_name",but i dont know how to view them on web.
Check it.
import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.Fields;
import com.google.analytics.tracking.android.MapBuilder;
public class YourBaseActivity extends Activity {
#Override
public void onStart() {
super.onStart();
EasyTracker tracker = EasyTracker.getInstance(this);
tracker.activityStart(this);
String trackingId = "UA-ABCDEFG-I";
tracker.set(Fields.TRACKING_ID, trackingId);
String category = "Activity Lifecycle Callback";
String action = "onStart()";
String label = "Screen: " + getClass().getSimpleName();
tracker.send(MapBuilder
.createAppView()
.createEvent(category, action, label, 0L)
.build();
);
}
#Override
protected void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
}
Then go to www.google.com/analytics/. Click Access Google Analytics.
And on the screen: tab Reporting (at the top panel) -> Real-time -> Events. And you'll see something like this (maybe not immediately, but within a few minutes):
Select category (at the bottom of the figure - here is CATEGORY_ACTIVITY_CALLBACK) and you'll see a number of actions:
But unfortunately I still have not found a way to see "not-realtime" data.
Sorry for my English
Follow these steps
open this link www.google.co.in/analytics/
Click on access Google Analytics button in the right side of the top most corner of this screen.
It will redirect you to your home screen. Here you can see your app name
Click on All Mobile App data link on home screen just below the title of your project
It will redirect you to App overview page.
It is where you want to be . Yo can see complete report and details of your app.
You may want to use Fiddler2 as a proxy to view the data.
open your Google Analycis account. You can check all the details related to the app. use this link
https://www.google.com/analytics/web/?hl=en#report/app-overvi/a46388977w77407404p80019218/
and Sign up the account.
When your offline to see the google analytics report follow the below steps.
Step 1. Go to Reporting
Step 2. Behavior and check Overview and Screens
Note: The total report will submit to google analytics once in 24hrs of time

Categories

Resources