Firebase Analytics doesn’t work for Web app

[REQUIRED] Describe your environment

  • Operating System version: macOS
  • Browser version: Firefox 72.0.2 (64-bit)
  • Firebase SDK version: 7.8.0
  • Firebase Product: analytics

[REQUIRED] Describe the problem

I’ve added a web app in Firebase console to integrate Firebase Analytics:

Screenshot 2020-02-06 at 08 20 37

The problem is Firebase Analytics doesn’t show any data for the web app. Like the website has no visits at all. I tried few ways to integrate Analytics:

<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-app.js"></script>
<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-analytics.js"></script>
<script>
  const firebaseConfig = {
    ...
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();
</script>
<script src="/__/firebase/7.8.0/firebase-app.js"></script>
<script src="/__/firebase/7.8.0/firebase-analytics.js"></script>
<script src="/__/firebase/init.js"></script>

nothing worked.

Quite similar issue described here: https://stackoverflow.com/questions/58484726/firebase-analytics-not-showing-data-for-web-application with no answer.

By the way, I use custom domain.

3 thoughts on “Firebase Analytics doesn’t work for Web app

  1. I believe the issue is that in this documentation, it isn’t apparent that you have to add this line after loading /__/firebase/init.js,

    <script>
      firebase.analytics().logEvent('notification_received');
    </script>
    

    Once I added that, analytics started working. I didn’t even add the logEvent(‘notification_received’); call, simply adding firebase.analytics(); will work.

  2. I’m having the exact same issue.

    The GA addon doesn’t log anything.

    Not sure if it matters but:

    • My stack is expo with react native web.
    • I am calling firebase.analytics()
    • Adding firebase.analytics().logEvent('notification_received'); doesn’t solve it
    • I’m testing on localhost.
    • The config has been set correctly.
    • The GA plugin doesn’t show anything on brave but…

    It works in google chrome. Events are being logged. it doesn’t work in any other browser. Not even other chromium based browsers like Brave or Edge are working.

    What other info can we provide to help resolve this?