Blocking firebase analytics events doesnt work with GTM - android

I am using firebase analytics in my app, and i track events like this:
public static String EVENT_MAIN_ACTIVITY_OPEN = "EVENT_MAIN_ACTIVITY_OPEN";
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Bundle bundle = new Bundle();
mFirebaseAnalytics.logEvent(EVENT_MAIN_ACTIVITY_OPEN, bundle);
These events are displayed normally in debug-view mode and in normal mode in firecase console.
Now, i want to block some events using GTM, without code fixes. How can i make this?
There are my variables, tags and triggers in GTM:
And I added GTM-xxxxx.json into main/assets/containers folder.
But event doesnt block (i track events view degub-view mode in firebase). So, how to resolve this?

Related

Why is Facebook's Unity SDK Not Logging Events To Analytics?

For some reason, I am unable to get the FB.LogAppEvent to work inside an android application built with Unity.
Based on the documentation I've read, the code below should work. But it's not producing results inside the analytics dashboard. You'll notice a method that produces an Android toast that confirms activation. This toast does appear on application start. I've tried multiple event types, including custom types from code generated by Facebook's event generator in the event documentation.
https://developers.facebook.com/docs/app-events/unity
https://developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent/
private void Awake()
{
if (!FB.IsInitialized)
FB.Init( () => { OnInit(); } );
else
ActivateFacebook();
}
private void OnInit()
{
if (FB.IsInitialized)
ActivateFacebook();
else
ShowAndroidToastMessage("Failed To Initialize Facebook..");
}
private void ActivateFacebook()
{
FB.ActivateApp();
ShowAndroidToastMessage("Facebook Activated..");
FB.LogAppEvent(AppEventName.ActivatedApp);
}
I suppose the problem is in the way you send event
There are two methods for that:
LogAppEvent(string logEventName);
LogAppEvent(string logEventName, float valueToSum, Dictionary parameters = null);
You are using second method with "valueToSum" = 0, and that indicates there is nothing to sum, so your event probably gets skipped at some point.
You should use the first method
FB.LogAppEvent(AppEventName.ActivatedApp);
Also make sure your analytics is enabled in dashboard.
Do you see any built in analytic events? Feg. App Launches and other Standard events should be visible out of the box.
For me, LogAppEvent(...) successfully works with the Facebook Events Tracker and Analytics when you do a development build with Unity. When I switch to a release build, I then do not get any of the LogAppEvents other than the ActivateApp() notification.
Will update my answer when I get it working with a release build.

Firebase Analytics not showing screen names and events

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.

How do I get GTM to run using Firebase?

I have a tough question. I looked around on the net, and while similar questions have been asked, this one hasn't. I'm currently building an Android app that uses Firebase and GTM.
I have the app setup correctly (I think). I added the appropriate lines to my gradle files, and when the app loads the debugger spits out the following:
I/FirebaseInitProvider: FirebaseApp initialization successful
It then says the following about GTM:
I/GoogleTagManager: Loading container GTM-XXX
I/GoogleTagManager: Installing Tag Manager event handler.
I/GoogleTagManager: Tag Manager event handler installed.
I/GoogleTagManager: Tag Manager initilization took 74ms
Thing is, I don't know how to track events, and the docs aren't very helpful. I have a event in GTM for 'session start' and that won't even fire. Furthermore, I tried the following code but it doesn't register in Firebase:
protected void onCreate(Bundle savedInstanceState) {
Log.d("asdf","Settings Activity create");
FirebaseAnalytics mFirebaseAnalytics;
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Log.d("asdf","Firebase object created");
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "id");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "name");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.LOGIN, bundle);
Log.d("asdf","Bundle sent");
// Bundle bundle = new Bundle();
// bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
// bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
// bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
// mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
super.onCreate(savedInstanceState);
setupActionBar();
}
My understanding of GTM is that I don't need to set it up on the device for it to run. My understanding is that you use the web browser app located here to setup all the tags, triggers, etc. The setup is then pushed onto your device and this allows you to turn events on/off at will. Its pretty handy, when it works.
What do I need to do to get GTM to work with my start session? What do I need to to do get Firebase to log events properly (one example here is more than enough)?
I can post the code for the project, but that seemed like overkill.
As per Google's questions:
The container has been published.
Firebase and GA analytics should be firing.
We get some feedback on firebase. It takes almost 24 hours for the events to show up though.
The GA info has never been published. See images below.
If you are using the Firebase+GTM SDK, you can setup in the GTM container session start trigger which is based on the automatically (out of the box) sent events from the Firebase+GTM SDK
Firebase should be automatically logging session start events. Can you try adding a trigger that matches event name "test", and then logging the following event via Firebase:
mFirebaseAnalytics.logEvent("test", new Bundle());

Debug Android Analytics event tracking - Analytics not picking up events

I've successfully added Analytics to an Android app and it is picking up session data just fine. However, I've also tried to track a specific event, but it does not seem to be sent to Analytics like the rest of the session data. I've followed the code suggested in the current Analytics documentation and still no luck, so I'm pasting here in the hopes that it's something obvious to more experienced folks. Many thanks in advance for any guidance.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_import);
user = getIntent().getStringExtra("user");
statusUpdateArea = (EditText)findViewById(R.id.dataStatusUpdateField);
progressBar = (ProgressBar)findViewById(R.id.progressBar);
progressBar.setVisibility(View.INVISIBLE);
welcomeMessage = (TextView)findViewById(R.id.WelcomeMessageTextView);
welcomeMessage.append(user);
// getting tracker & setting User ID field
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
mTracker.set("&uid", user);
// build and send event
mTracker.send(new HitBuilders.EventBuilder()
.setCategory("User ID")
.setAction("Data login")
.setLabel(user)
.build());
...
maybe you need use
mTracker = application.getTracker();
and
mTracker.setScreenName("yourscreenname");
Seems you are calling send before calling build .
Create a tracker with all the event info then call build and once done call send function .
Have worked on webtrends analytics product so I know a thing or two about analytics

Android Google Tag Manager does not work

I'm having trouble while implemented the new google tag manager lib.
Here is what I did:
I create a macro dataleyr
I set a rule for an event
I create a tag and set the universal analytics ID on it
I publish my container
Then I tried to use it in my app like this
TagManager mTagManager = TagManager.getInstance(this);
DataLayer mDataLayer = com.google.android.gms.tagmanager.TagManager.getInstance(this).getDataLayer();
ContainerOpener.openContainer(
mTagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT,
TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, new ContainerOpener.Notifier() {
#Override
public void containerAvailable(Container container) {
container.refresh();
// Save container for use by any other activities in the app.
com.appsconceptelite.appsconceptelite.testfunctionnalities.gtm.ContainerHolder.setContainer(container);
mContainer = com.appsconceptelite.appsconceptelite.testfunctionnalities.gtm.ContainerHolder.getContainer();
Utils.pushOpenScreenEvent(LearnActivity.this, "Learn Screen");
}
});
and the method I use to push event is
/**
* Push an "openScreen" event with the given screen name. Tags that match that event will fire.
*/
public static void pushOpenScreenEvent(Context context, String screenName) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("openScreen", DataLayer.mapOf("screenName", screenName));
}
When I run this code in debug mode, I get the right container name and version but when I check in Google Analytics dashbord, I see no events like if no data have been pushed.
Can you tell me what I'm doing wrong?
Not sure if it will solve the issue but what tripped me is the old google analytics account that hasn't been created a "Mobile apps" account and no results would be seen on the account but were definitely sent out. Create a new "Mobile apps" property and try again.

Categories

Resources