snowykz
snowykz

Reputation: 256

Firebase + GTM + GA implementation issue

I am using iOS Swift 3 and trying to track screen views in Firebase and push those data into GA with GTM.

My issue is that I cannot get the screen name from "screen_view" events pushed into GA.

In firebase, the initial automated screen view hit has no screen name and only screen class so I used Analytics.setScreenName to set the screen name and override the screen class.

However this causes two hits in Firebase, one automated with no screen name and one manually triggered with screen name.

Also, I want to pass the screen name from the event into GA as a screen view type. I set the screenName field in GTM to a variable.

I have tried various event parameters for the variable

So I guess all the parameters that start with _ are reserved in Firebase. So how do I get the reserved event parameters from firebase into GA. For example, I may want to store the App Version in a custom dimension for something.

The biggest problem here is the screen name not picking up in the screenview hit from GTM to GA.

Upvotes: 5

Views: 2403

Answers (1)

Jack
Jack

Reputation: 446

In Google Tag Manager you'll want to set the following:

Tag type: Universal Analytics (Google Analytics) Track Type: Screen View

Field Name: screenName Value: [the variable I've identified below]

Trigger: Fire on "Event Name" contains screen

** Note the Trigger might be better as matches "screen_view", but I haven't had a chance to test

Variable:

Variable Type = Event Parameter

Event Type = Custom Parameter

Event Parameter Key = _sn

Other Things Make sure the Analytics.setScreenName is working and in ViewDidAppear as that fills the _sn parameter.

Xcode Debug Example In Xcode you should see something such as:

 firebase_screen_id (_si) = 4233194112313113131331;

 firebase_screen_class (_sc) = ViewController;

 firebase_screen (_sn) = Home View;

 firebase_realtime (_r) = 1;

 firebase_debug (_dbg) = 1;

 firebase_event_origin (_o) = auto;

Upvotes: 7

Related Questions