Ok. I was quite confused for the first time. I will answer to my question in a more simple way. Please refer to images from the first answer for a better idea.
Objective: Push events from mobile app to both Firebase and Google Analytics (GA)
In my question i have asked, how to copy the events from FA to GA using tagmanager.
My event > Firebase > Google tag manager > Google analytics
I am changing this as follows. Because this is how it works. Only thing is GTM and FA are connected internally so that you only need to logEvent using FA and it will be captured by GTM, just by adding the dependency in Gradle(V5+).
My event > Firebase
My event > Google tag manager > Google analytics
I will explain few basic terms in GTM to get started.
- Event Parameter - Variables that will be used to extract data from
Key-Value params send from app
- Constants - Similar to variables. Values will be constant as defined
on dashboard
- Trigger - Trigger is used to fire a tag when a FA event is logged
from app
- Tags - Tag carries data and is pushed from GTM to GA so that an event is logged on GA
The logic is simple. We need to create a Trigger which will push a Tag to GA. To carry the data from GTM we use an Event parameter variable.
Follow the below link to learn how to log a FA event.
https://firebase.google.com/docs/analytics/android/start/
Follow below link to learn how to use GTM with Firebase.
https://developers.google.com/tag-manager/ios/v5/
Say, i want to log an event as below.
bundle.putString("button_click", "Login button");
mFirebaseAnalytics.logEvent("user_interactions", bundle);
Essentially we are sending 3 data items from app.
- Event parameter - button_click
- Event parameter value - Login button
- Event name - user_interactions
Now, to capture the above data and push to GA we create variables/Tags/Triggers as follows.
Button click variable - Create a new Variable of type Firebase > Event parameter. Set value to Custom parameter. Value as "button_click"
Button click trigger - Create a new trigger and set the trigger to fire on Event = "user_interactions"
Button click tag - Create a tag with Universal analytics(GA) as tag type. Because we are going to push this to GA. Inside the Tag configuration, choose Track type as Event, and now you can set Category/Label/Action/Value etc here. Remember that Category and Action are mandatory. Click the icon next to Action field and choose the button_click event parameter variable. This will pass the value matching key = button_click. Set this tag to fire on above trigger. Check the "Enable overriding settings" option and set you Google analytics key here.
Now save your configurations and publish the container. Download and copy the container to app and run your app.
When you log an event in app, typically event will log in your GA console in Realtime tab within one or two minutes. If you have configured it correctly, when the app is running, it will show number of active users as greater that 0. Note that you don't need to enable debug mode. But it's always good to ensure that events are logged on Firebase console.