Dan G
Dan G

Reputation: 183

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.

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.

Upvotes: 3

Views: 913

Answers (2)

Dmitry
Dmitry

Reputation: 792

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

enter image description here

Upvotes: 1

Eric Burley
Eric Burley

Reputation: 576

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());

Upvotes: 0

Related Questions