I am trying to use Firebase´s Google Analytics for my Nextjs App.
Problem is i live in Germany and i am only allowed to use Analytics after user Opt-in.
My Config looks like that:
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
const firebaseConfig = {
//my Config
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
I have a Cookie Consent Component where the user can Accept or Decline the use of Cookies. On Accept i want to initialize Firebase analytics. Is it possible to export the analytics and initialize it in the Cookie Consent Component after the user Input?