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?
I am kind of getting swamped by this topic too. Perhaps you could initialize with const analytics = getAnalytics(app).setAnalyticsCollectionEnabled(false); and then set it true on accept.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With