How to log Firebase Analytics event via Cloud Function? [duplicate] - firebase

Is there any way to perform Server-side event tracking?
Every call to my Firebase function, has to go through multiple steps. I couldn't monitor it through console logs. Actually I need to prepare an report at end of every week and month.
Looking for the better way to do this. Is there any better tool available other than Google Analytics?
Appreciate your help!

As of late 2020 it is possible to log events from server-side code with the Analytics Data API and the GA4 Measurement Protocol documentation on sending events with this REST API, which you can use from Cloud Functions (and almost any other environment).
Old answer 👇
There is no server-side API for Google Analytics for Firebase.
Some options to consider:
Insert events directly from the clients that also trigger the Cloud Functions.
Use regular Google Analytics for these stats.
Insert the events into BigQuery and use Data Studio for reporting.

Related

How to log events into Firebase Analytics from server side? [duplicate]

Is there any way to perform Server-side event tracking?
Every call to my Firebase function, has to go through multiple steps. I couldn't monitor it through console logs. Actually I need to prepare an report at end of every week and month.
Looking for the better way to do this. Is there any better tool available other than Google Analytics?
Appreciate your help!
As of late 2020 it is possible to log events from server-side code with the Analytics Data API and the GA4 Measurement Protocol documentation on sending events with this REST API, which you can use from Cloud Functions (and almost any other environment).
Old answer 👇
There is no server-side API for Google Analytics for Firebase.
Some options to consider:
Insert events directly from the clients that also trigger the Cloud Functions.
Use regular Google Analytics for these stats.
Insert the events into BigQuery and use Data Studio for reporting.

Need a better solution than google analytics for data visualization dashboard

I trying to find a better solution than google analytics to create dashboards for visually representing custom data.
My use case is that I need something to track and record custom data that is not passed in through custom web events into google analytics.
I was able to find a hacky solution to the problem initially by running a periodic function over my data on firebase and sending it as custom events to google-analytics. (I mention the approach in this answer. The linked blog post gives further details.)
The problem that I faced was that it wasn't always reliable as although the function did run successfully every day, the data was not shown in the google analytics dashboard.
The data I to visualize is gathered as further insights by writing basic code on existing data
I am aware that it is possible to integrate google analytics for various use cases like even the smallest button click, but I am trying to either send custom events( raised outside of the application by running cron jobs or scheduled functions ) through some API call or maybe directly save and update the data in some other place where there is direct access to visualization
Does anyone know a better solution?
The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers, so you can use it to send your data generate outside your application:
https://developers.google.com/analytics/devguides/collection/protocol/v1

How to store firebase analytics data offline for more than 72 hours?

I am using Firebase for analytics and I have enabled firebase persistent storage which helps to send the analytics events to firebase when the device comes online but the limitation is it only sends 72 hours data to Firebase analytics.
I want firebase to get at least offline analytics data of the last 10 days.
Can I achieve this by storing this analytics event in core data when the device is offline and send this event to firebase when the device is connected to the internet?
Or is there any alternative way to achieve this?
I only want to send the event name and timestamp of the event.
You can probably do something to store the events locally, but it'll be finicky and error prone.
When storing the events yourself and then submitting them when the device is online, I see many potential problems. Off the top of my head:
There is no API to track the lifecycle of Firebase's built-in purging of analytics event. So you have a decent chance of events being logged twice.
You can't backdate the events, so any events you fire upon reconnecting are going to show up as having happened then.
You're likely going to miss events that Firebase logs automatically. You could probably compensate, but at that point you're almost building your own Analytics solution.
Honestly that is some of the potential problems, and you're likely to encounter many more. I'd seriously consider if the effort is really worth it, or if you'd be better off picking another solution.
Some solutions that come to mind:
Log your own events directly to BigQuery. Then merge then with Firebase's exported Analytics events, and deduplicate the results.
Pick an analytics provider whose API meets your requirements directly.

GET Goals from Google Analytics using API Method with Date Range

I am trying to get the goals from our google analytics account but applying a date range. I haven't seen in the documentation a way to pass a date range for this method. Any help would be appreciated! Thanks!
Testing using their API test page here: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/goals/get
GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/goals/goalId
When I pull the request using the their test API page, I am assuming it is only pulling the goal conversions for the day I am making the request, not for all of time.
I think you might be confusing the reporting api with the management api.
If you want to get data out of GA, use the reporting api.
If you want to configure GA or read GA configurations, use the management api.
In your case, you want to REPORT on the goals, but you're using the management api to do so.
You should use the reporting API to get a list of goals completed.
Reporting API reference/documentation: https://developers.google.com/analytics/devguides/reporting/core/v4/

Can I track my Firebase function in Google Analytics?

Is there any way to perform Server-side event tracking?
Every call to my Firebase function, has to go through multiple steps. I couldn't monitor it through console logs. Actually I need to prepare an report at end of every week and month.
Looking for the better way to do this. Is there any better tool available other than Google Analytics?
Appreciate your help!
As of late 2020 it is possible to log events from server-side code with the Analytics Data API and the GA4 Measurement Protocol documentation on sending events with this REST API, which you can use from Cloud Functions (and almost any other environment).
Old answer 👇
There is no server-side API for Google Analytics for Firebase.
Some options to consider:
Insert events directly from the clients that also trigger the Cloud Functions.
Use regular Google Analytics for these stats.
Insert the events into BigQuery and use Data Studio for reporting.

Resources