11

We've developed a mobile app using Firebase and we want to add analytics. We want to add to the analytics several system events that are triggered from existing cloud functions. I do not see any way to log an event from a cloud function and the only way I see is from the client side. Is there a way we can log event from the server side ?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Philippe Cohen
  • 1,070
  • 1
  • 10
  • 15
  • Start by looking at the [Cloud function triggers](https://firebase.google.com/docs/analytics/extend-with-functions) for analytics. This is not what you want per-se, but a good starting point to realize that you can use [functions.analytics](https://firebase.google.com/docs/reference/functions/functions.analytics#.event) to grab an event builder and (possibly) trigger an event. – James Poag Aug 26 '18 at 13:47
  • See https://stackoverflow.com/questions/50355752/firebase-analytics-from-remote-rest-api, https://stackoverflow.com/questions/38232464/is-there-any-rest-api-to-send-data-to-firebase-analytics – Frank van Puffelen Aug 26 '18 at 14:12

1 Answers1

7

There is no server side logging for Analytics events. Analytics requires information available only on the client in order to construct an event, and backend code doesn't have access to that information. If you need to log something on the server for use with analytics, you would have to log to another destination, and then export it all (including events originating from Firebase) to BigQuery to match up later for querying.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Google Analytics now lets you send events from your backend. See the Google Analytics documentation on [Sending events](https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?hl=en&client_type=gtag#required_parameters) or this [other StackOverflow thread](https://stackoverflow.com/questions/50355752/firebase-analytics-from-remote-rest-api) – Frenchcooc Feb 21 '23 at 09:51