firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.46k stars 3.91k forks source link

[firebaseAnalytics]: logScreenView doesn't send the name and class to GA4 in flutter web #12751

Closed JgomesAT closed 2 weeks ago

JgomesAT commented 3 weeks ago

Is there an existing issue for this?

Which plugins are affected?

Analytics

Which platforms are affected?

Web

Description

I have this code FirebaseAnalytics.instance.logScreenView(screenName: screenName, screenClass: className); to send the event to screenView, and in the Ga4 I can see the events of screenView but without screenName and screenClass, this only happened with Flutter Web in Android and iOS work perfectly. other events in the web dork fine like purchase ¡, in this case, I can see all parameters of the event.

Reproducing the issue

Create an event with this faclility FirebaseAnalytics.instance.logScreenView(screenName: screenName, screenClass: className);

Firebase Core version

2.30.1

Flutter Version

3.19.6

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Replace this line with the contents of your `flutter pub deps -- --style=compact`. ```

Additional context and comments

No response

TarekkMA commented 3 weeks ago

Hello @JgomesAT, Can you try this code instead of logScreenView(......) for web.

   analytics.logEvent(
      name: 'screen_view',
      parameters: {
        'firebase_screen': screen_name,
        'firebase_screen_class': screen_name_class,
      },
    );
JgomesAT commented 3 weeks ago

I just found this option and since the last week I have this code:

static void logScreenView(String screenName, String className, {Map<String, dynamic>? parameters}) { logEvent( 'screen_view', parameters: <String, dynamic>{ 'screen_name': screenName, 'screen_class': className, "cookie_consent": CookieUtils.getCookieValue(CookieUtils.kCookieIdCookieGprd, encripted: false) == "true" ? "granted" : "denied", }, );

but the behavior is the same

in your example you put parameters: { 'firebase_screen': screen_name, 'firebase_screen_class': screen_name_class, },

I will change my code with your feedback and I'll say something

TarekkMA commented 3 weeks ago

@JgomesAT Okay waiting for your reply.

JgomesAT commented 3 weeks ago

I think isn't working, in GA4 I can see events of screen_view on web but with out screenNAme, and in Android and iOS its OK

event event_1
TarekkMA commented 3 weeks ago

Does it work on the firebase console?

JgomesAT commented 3 weeks ago

HOw Can I Prove it in the firebase console?

JgomesAT commented 3 weeks ago

In the firebase console I see the same info,

firebase_conole
TarekkMA commented 3 weeks ago

I've tested using this chrome extension and I found that data is being sent correctly via the SDK. Can you please try and see if that's the case for you also?

https://chromewebstore.google.com/detail/taghound-analyticsgtmpixe/canpneabbfipaelecfibpmmjbdkiaolf

JgomesAT commented 3 weeks ago

OK, thanks I will try this extension

JgomesAT commented 3 weeks ago

I can see this:

Event Data 10 Language es-es

Page Location https://www.andorratelecom.ad/botiga/

Page Title Andorra Telecom

Screen Resolution 1920x1080 Session Count 1

Session ID 1715330811

ep.cookie_consent granted

ep.firebase_screen Dashboard_Particular

ep.firebase_screen_class minified:DE

ep.origin firebase

these two events are related to the name and class of screen_view:

ep.firebase_screen Dashboard_Particular

ep.firebase_screen_class minified:DE

I don't understand the class minified:DE this Is not a class of my project

JgomesAT commented 3 weeks ago

In the screen_class I set the same value as screen_name and now I Can see values the problem was the value of screen_class

TarekkMA commented 3 weeks ago

Based on the snippet you've shared, it seems like it correctly reports screen_view to GA, but the issue might be on the backend side.

Does the issue still happens?

JgomesAT commented 2 weeks ago

It seems that is now working, I can see the screen's name in the GA4 for the web, I force for now in the attribute screenClass the same value of screenName

TarekkMA commented 2 weeks ago

What snippet of cope you used the one with firebase_screen_class and firebase_screen_class?

If so can you please confirm again if logScreenView is working or not?

Thank you

JgomesAT commented 2 weeks ago

I've just prepared a version of my code to rollback to the initial logScreenView , I will try and notify the behavior THX

JgomesAT commented 2 weeks ago

I have data in GA4!,

I think all the problems were related to the codification of screenClass

thanks for the support

TarekkMA commented 2 weeks ago

Glad to hear that the issue have been resolved 🥳