Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_analytics] Screen_view/page_view and user_engagement events are not being sent for web #4910

Closed
SaltumDis opened this issue Feb 2, 2021 · 16 comments
Assignees
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot plugin: analytics Stale Issue with no recent activity type: bug Something isn't working

Comments

@SaltumDis
Copy link

SaltumDis commented Feb 2, 2021

When using firebase_analytics for web events are sent only on refresh

I am using FirebaseAnalyticsObserver. For mobile it works, but for web - events are only sent when I open page for the first time or refreshed. 😿

FirebaseAnalytics analytics = FirebaseAnalytics();

MaterialApp(
  home: MyAppHome(),
  navigatorObservers: [
    FirebaseAnalyticsObserver(analytics: analytics),
  ],
);

Have also tried using custom navigatorObserver and sending page_view events on navigation - would receive them, but would not get any user engagement data.

void _sendScreenView(PageRoute<dynamic> route) {
    final String screenName = nameExtractor(route.settings);
    if (screenName != null) {
      analytics.setCurrentScreen(screenName: screenName).whenComplete(() {
        analytics.logEvent(name: "page_view");
   .....

Flutter doctor

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 1.23.0-18.1.pre, on Mac OS X 10.15.7 19H15 x86_64, locale en-LT)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Community Edition (version 2019.1.3)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

Flutter dependencies

Click To Expand
Dart SDK 2.11.0-213.1.beta
Flutter SDK 1.23.0-18.1.pre
xxx 1.0.0+1

dependencies:
- cupertino_icons 0.1.3
- dio 3.0.10 [http_parser path]
- firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- fluro 1.6.3 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_bloc 3.2.0 [flutter bloc provider]
- rxdart 0.23.1
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- xxx_lib 0.0.1 [flutter universal_html json_annotation dio flutter_bloc uuid intl mask_text_input_formatter date_range_picker flutter_range_slider dropdown_search url_launcher transparent_image tuple charts_flutter share http multi_image_picker shared_preferences]
- xxx_lib 0.0.1 [flutter firebase_analytics]

dev dependencies:
- build_runner 1.10.2 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
- intl_translation 0.17.10+1 [analyzer args dart_style intl path petitparser]
- json_serializable 3.4.1 [analyzer build build_config json_annotation meta path source_gen]
- transparent_image 1.0.0

transitive dependencies:
- _fe_analyzer_shared 7.0.0 [meta]
- analyzer 0.39.17 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob html meta package_config path pub_semver source_span watcher yaml]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- bloc 3.0.0 [meta rxdart]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- build 1.3.0 [analyzer async convert crypto logging meta path glob]
- build_config 0.4.2 [checked_yaml json_annotation meta path pubspec_parse yaml]
- build_daemon 2.1.4 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 1.3.11 [analyzer build crypto graphs logging path package_config pub_semver]
- build_runner_core 6.0.1 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml]
- built_collection 4.3.2 [collection quiver]
- built_value 7.1.0 [built_collection collection fixnum quiver]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- charts_common 0.9.0 [collection intl logging meta vector_math]
- charts_flutter 0.9.0 [charts_common collection flutter intl logging meta]
- checked_yaml 1.0.2 [json_annotation source_span yaml]
- cli_util 0.2.0 [path]
- clock 1.1.0-nullsafety.1
- code_builder 3.5.0 [built_collection built_value collection matcher meta]
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- csslib 0.16.2 [source_span]
- dart_style 1.3.6 [analyzer args path source_span]
- date_range_picker 1.0.6 [flutter]
- dropdown_search 0.4.8 [flutter]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase 7.3.3 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- fixnum 0.10.11
- flutter_range_slider 1.5.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- graphs 0.2.0
- html 0.14.0+4 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- intl 0.16.1 [path]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.3-nullsafety.1
- json_annotation 3.0.1
- logging 0.11.4
- mask_text_input_formatter 1.1.0 [flutter]
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.4
- mime 0.9.7
- multi_image_picker 4.6.7 [flutter meta]
- nested 0.0.4 [flutter]
- node_interop 1.2.1 [js]
- node_io 1.2.0 [file node_interop path]
- package_config 1.9.3 [path charcode]
- path 1.8.0-nullsafety.1
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- pool 1.4.0 [async stack_trace]
- process 3.0.13 [file intl meta path platform]
- provider 4.3.2+2 [flutter nested collection]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml]
- quiver 2.1.5 [matcher meta]
- share 0.6.5+4 [meta mime flutter]
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_gen 0.9.7+1 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.2 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timing 0.1.1+2 [json_annotation]
- tuple 1.0.3 [quiver]
- typed_data 1.3.0-nullsafety.3 [collection]
- universal_html 1.2.3 [async charcode collection csslib html meta typed_data universal_io zone_local]
- universal_io 1.0.1 [meta zone_local]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- win32 1.7.4 [ffi]
- xdg_directories 0.1.2 [meta path process]
- yaml 2.2.1 [charcode collection string_scanner source_span]
- zone_local 0.1.2
@SaltumDis SaltumDis added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Feb 2, 2021
@markusaksli-nc
Copy link
Contributor

I'm seeing this as well on the latest master 1.26.0-18.0.pre.156 with firebase_analytics: ^7.0.1.

flutter doctor -v
[√] Flutter (Channel master, 1.26.0-18.0.pre.156, on Microsoft Windows [Version 10.0.19041.746], locale et-EE)
    • Flutter version 1.26.0-18.0.pre.156 at C:\Development\flutter_master
    • Framework revision 45508985b1 (6 hours ago), 2021-02-02 22:46:04 -0500
    • Engine revision 2c144c3eeb
    • Dart version 2.12.0 (build 2.12.0-282.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (4 available)
    • SM G950F (mobile) • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • Windows (desktop) • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.746]
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 88.0.4324.104
    • Edge (web)        • edge               • web-javascript • Microsoft Edge 88.0.705.56

• No issues found!

@markusaksli-nc markusaksli-nc added plugin: analytics and removed Needs Attention This issue needs maintainer attention. labels Feb 3, 2021
@SaltumDis
Copy link
Author

Any ideas what causes it? Have not found any workarounds for now...

@markusaksli-nc
Copy link
Contributor

Not sure, analytics web support should be official so it should work fine but I've had a hard time getting the events to register in general.

Can't really offer a workaround, will have to wait until this gets investigated.

@jameshmread
Copy link

I have the same issue for flutter web beta and 2.0. Events seem to be showing in the firebase console but screen views aren't. Using the Chrome firebase Analytics debugger extension shows the screen view "events" are being fired. But there is nothing in the Firebase / GA consoles or stream views. The only page view event happens on app start which shows the app name as the page view and "main activity"

@GringoDotDev
Copy link

GringoDotDev commented Aug 5, 2021

Seeing this on 2.2.3 as well. Inspected FirebaseAnalyticsObserver under the debugger and it is running as expected (i.e. it successfully extracts the screen name and calls analytics.setCurrentScreen with it). For some reason that doesn't seem to trigger the underlying event for web.

@steebchen
Copy link

steebchen commented Sep 6, 2021

I can also confirm. No screen events fired on web but custom events work fine. Would be great to get this fixed to prevent seeing skewed data.

@steebchen
Copy link

This seems related: googlearchive/firebase-dart#312

@hamirshekhawat
Copy link

Is anyone able to connect to debug view in firebase console using the chrome extension. I am on flutter beta. I can't even see my app in debug view.

@leidig54
Copy link

Same issue on web. Unable to manually track screen views with FirebaseAnalytics().setCurrentScreen().

[✓] Flutter (Channel stable, 2.5.2, on macOS
    11.6 20G165 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android
    devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.0)
[✓] Connected device (2 available)

@mdrideout
Copy link

mdrideout commented Nov 4, 2021

I also cannot get setCurrentScreen() to work correctly on Flutter Web. I only see the "page_view" with a generic title for the app. The screen name is not anywhere.

I am using function:

firebaseAnalytics.setCurrentScreen(screenName: screenName);

I see this output in the browser console, however, there is no data logged to Firebase analytics in the normal view or the debug view.

GTAG Command: "config", target: "G-EQ8J6SB3W0", configuration: {update: true, screen_name: "/test-screen-1"}
GTAG Command: "config", target: "G-EQ8J6SB3W0", configuration: {update: true, screen_name: "/test-screen-2"}

I am assuming that the implementation is just broken.

Workaround / Solution

Use the logEvent() function to log a screen_view event manually, only for web. See documentation here about creating a custom screen_view event.

Web / iOS / Android consistent Analytics screen_view tracking

      if (kIsWeb) {
        firebaseAnalytics.logEvent(name: "screen_view", parameters: {
          'firebase_screen': screenName,
          'screen_name': screenName,
        });
      } else {
        firebaseAnalytics.setCurrentScreen(screenName: screenName);
      }

This works successfully, and shows the screen_view in the debug view, with the screen_name attached for web. For iOS / Android, the debug view does not show screen_name, rather, it shows firebase_screen only.

However, in the full analytics view, I am able to correctly see the screen_name for all 3 platforms (web / ios / android). I include firebase_screen on web for consistency reasons. This data is visible in the full analytics view under Life cycle -> Engagement -> Engagement overview -> USERS IN LAST 30 MINUTES (box) -> Top Pages & Screens.

UPDATE

I've updated my implementation because Google Analytics combines Screen Name and Page Title into the same metric / field in many reports. iOS / Android / Web were reporting Page Title differently.

Since I personally only care about "screen_name", this tracking style will report screen name and page title identically, making the reports work better (especially the "explore" funnel / path reports).

The analytics plugin will still report "page view" separately from "screen view" - page view evidently being the "entrance" to the app, and screen view being transitions within the app. We don't seem to have any control over "page view" which is being done automatically.

I am using this code to only log screen_view to get the more consistent cross-platform output. This makes sense for me using a router compatible with web, and my screen names are basically all url path templates which work identically across ios / android / web. There are no longer confusing differences of "page_title" and "screen_name" being shown in Analytics. The data is uniform.

This is the same for all platforms.

    firebaseAnalytics.logEvent(name: "screen_view", parameters: {
        'screen_name': screenName,
        'page_title': screenName,
      });

@russellwheatley
Copy link
Member

Hey @SaltumDis, Firebase Analytics plugin was reworked & released in December 2021. Are you able to confirm if you're still experiencing the same problem for the latest version? Thanks.

@SaltumDis
Copy link
Author

@russellwheatley yes, this issue still persists with firebase_analytics: ^9.0.5

@russellwheatley
Copy link
Member

Hey @SaltumDis, I've just tested the analytics example and used the Google Analytics Debugger to test. Events were being fired on every screen transition. Could you provide a reproducible sample, please?

@russellwheatley russellwheatley added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Feb 1, 2022
@steebchen
Copy link

@russellwheatley As far as I remember, I think they always show as triggered, but they just never show up properly in Google Analytics, so one would need to verify that they actually do show up correctly in GA.

@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Feb 10, 2022
@google-oss-bot
Copy link

Hey @SaltumDis. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@SaltumDis if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot plugin: analytics Stale Issue with no recent activity type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants