I try to do something simple, import firebase in my index.html and start analytics.
I import the code, but i have ReferenceError: firebase is not defined
. Please what is wrong with my code ?
<body>
<script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js"></script>
<script>
// Initialize Firebase with your configuration
const firebaseConfig = {
apiKey: "AIzaSyDMOXXXXXXXXXXXu6fMbeqU",
authDomain: "XXXXXXXXXXXXXXXXXXXe.firebaseapp.com",
projectId: "XXXXXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXXXXXXXX.appspot.com",
messagingSenderId: "XXXXXXXXXXXXXXXXXXXXXX3370",
appId: "1:XXXXXXXXXXXXXXXXXX:web:XXXXXXXXXXXXXXXXXXXXXXX",
measurementId: "G-XXXXXXXXXXXXXXXX"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Initialize Firebase Analytics
const analytics = firebase.analytics();
// Log an event (optional)
analytics.logEvent('star_html5_game');
// You can start tracking events and user interactions here
</script>
</body>