node.jsfirebasegoogle-analyticsgoogle-cloud-functionsanalytics

Firebase Analytics log custom events from server


I want to send firebase Analytics custom log event from Firebase Functions (with node.js). I have searched a lot but I couldn't find any tutorial or ducumentation about it. Is there any way to send custom event to firebase analytics from backend in 2024? I have tried to send log with

admin.analytics().log()...

but there was a syntax error analytics is not a function


Solution

  • You don't send events from your backend to Firebase. Firebase is a proxy endpoint for analytics data collected from apps. It's a proxy in a sense that the analytics data in Firebase is essentially unusable. You proxy it to a GA4 instance from Firebase.

    GA4 allows direct tracking from backend using the measurement protocol. Be very careful with the measurement protocol. It requires you to set a lot of ids if you want this data to be connected to the rest of it. And if this thing in Node that you want to track doesn't need to be connected to the rest of user activity, then GA/Firebase is definitely a wrong tool to use for it.

    Still, you can use the Firebase sdk by routing your Node events through the apps and then having apps translating those into analytics payloads.