Firebase analytics not showing data for web application

Viewed 3264

I want to use Firbase analytics for a web application , i added the web project in the console and copier the snippet code at the end of the body tag.

here is the snippet code :

<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.2.1/firebase-app.js"> 
</script>

<!-- TODO: Add SDKs for Firebase products that you want to use
 https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.2.1/firebase-analytics.js"> 
</script>

<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "..-WY",
authDomain: "....firebaseapp.com",
databaseURL: "https://.....firebaseio.com",
projectId: "app-id",
storageBucket: "app-name.appspot.com",
messagingSenderId: "1122255",
appId: "1:22233355:web:fffff",
measurementId: "G-123J"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>

firebase is not showing any data since 3 days , what's can be wrong ?

2 Answers

No solution, responding for further discussion.

In my case I have the web-app linked to a firebase hosted site so the configuration is set to automatic with the "reserved hosted URLs". The snippet in my case is just linking and initializing the SDK:

<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="/__/firebase/7.2.1/firebase-app.js"></script>

<!-- TODO: Add SDKs for Firebase products that you want to use
     https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="/__/firebase/7.2.1/firebase-analytics.js"></script>

<!-- Initialize Firebase -->
<script src="/__/firebase/init.js"></script>

It's been configured and deployed for around 48 hours but likewise I am not seeing any data in the firebase analytics dashboard.

I do have multiple websites per project, with their own sub-domains, but I would not expect that to cause any issues.

You need to put this before the closing of the body tag and after firebase bootstrapping is complete.

<script> 
  firebase.analytics();
</script>
Related