Server-side gtm with Firebase es6 modules
By Ryan Romanchuk
On
On
// app/javascript/initialize.js
import { initializeApp } from "firebase/app";
const firebaseConfig = {
apiKey: "",
authDomain: "foo-bar.firebaseapp.com",
projectId: "foo-bar",
storageBucket: "foo-bar.appspot.com",
appId: "foo:web",
measurementId: "G-firebase-web-data-stream"
};
const firebaseInit = () => {
return initializeApp(firebaseConfig);
}
export {firebaseInit}
// app/javascript/application.js
import { getAnalytics } from "firebase/analytics";
import { firebaseInit } from "initialize";
const firebaseApp = firebaseInit()
const analytics = getAnalytics(firebaseApp, {debug_mode: true, transport_url: 'https://custom.tld.com'});
export { analytics };