I’m newbie to Firebase Analytics Web implementation.
But here’s my code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
http-equiv="Cache-control"
content="no-cache, no-store, must-revalidate"
/>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>Firebase test</title>
<base href="./" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, shrink-to-fit=no"
/>
</head>
<body>
Hello :)
<button onclick="logMyEvent()">Log an event</button>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js";
import { getAnalytics, logEvent } from "https://www.gstatic.com/firebasejs/10.13.1/firebase-analytics.js";
const firebaseConfig = {
apiKey: "xxx",
authDomain: "xxx.firebaseapp.com",
projectId: "xxx",
storageBucket: "xxx.appspot.com",
messagingSenderId: "000",
appId: "xxx000",
measurementId: "G-xxx"
};
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
logEvent(analytics, 'test_init', { 'data': 'init' });
window.logMyEvent = function() {
console.log('Button was clicked!', analytics); // `analytics` is already defined.
logEvent(analytics, 'test_button_click', { 'data': 'click' });
};
</script>
</body>
</html>
As you can see this is just a basic Firebase Analytics implementation! But I don’t see my events being logged in the ‘DebugView‘ (or ‘Realtime Analytics’ page) of my Firebase project… Am I missing something?
In the ‘DebugView’, I also see this message: ‘Debug Device: 0, No devices available‘, although I have already installed ‘Google Analytics Debugger‘ Chrome extension and turned it on.
Any help is appreciated. Thanks in advance.