- First of all, you need Your web app’s Firebase configuration.
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: “apiKey”,
authDomain: “authDomain”,
databaseURL: “databaseURL”,
projectId: “projectId”,
storageBucket: “storageBucket”,
messagingSenderId: “messagingSenderId”,
appId: “appId”,
measurementId: “measurementId
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
- Your Firebase configures are complete after setting the following code to set user id into events.
firebase.analytics().setUserId(“Your User id”);
Read more about why we need to set user id in the firebase event?.