问题
How can I get firebase analytics data using HTTP request or api? I want to show firebase analytics data on my website
回答1:
You can't directly do this from http or api. But you need to export to BigQuery and there you can query the data. I am not much aware of hoe BigQuery works and how you can fetch and show data on websites but you can not do this in your free plan.
You can export war analytics data to BigQuery in BLAZE plan. And then you can query from the BigQuery database.
回答2:
Google BigQuery, access to project (here you'll write SQL queries to fetch data): https://bigquery.cloud.google.com/dataset/
Google BigQuery Documentation: https://cloud.google.com/bigquery/docs/
Quickstart Using the Web UI: https://cloud.google.com/bigquery/quickstart-web-ui
BigQuery Tip: The UNNEST Function (helps to split array data to single items): https://firebase.googleblog.com/2017/03/bigquery-tip-unnest-function.html
-----------------------------------
#standardSQL
SELECT
field_1, field_2, field_N
FROM `datasetName.tableName`,
WHERE
field_1 = 'something'
--------Examples-------------------
#standardSQL
SELECT
*
FROM
`bigquery-public-data.samples.natality`
WHERE
year = 1969
AND state = 'CA'
LIMIT 100;
-----------------------------------
#standardSQL
SELECT
repository,
actor_attributes.blog,
actor_attributes.email
FROM
`bigquery-public-data.samples.github_nested`
WHERE
repository.has_downloads = true
LIMIT 10;
-----------------------------------
#standardSQL
SELECT
repository,
actor_attributes.blog,
actor_attributes.email
FROM
`bigquery-public-data.samples.github_nested`
WHERE
repository.language = 'Java'
LIMIT 10;
-----------------------------------
#standardSQL
SELECT
*
FROM
`bigquery-public-data.samples.github_nested`
WHERE
repository.language = 'Java'
LIMIT 10;
-----------------------------------
#standardSQL
SELECT
*
FROM
`myProjectDatasetName.app_events_20180118`
WHERE
user_dim.geo_info.city = 'Moscow'
#LIMIT 10;
-----------------------------------
#standardSQL
SELECT
*
FROM
`myProjectDatasetName.app_events_20180118`
WHERE
user_dim.user_id = '5365621384'
#LIMIT 10;
-----------------------------------
#standardSQL
SELECT event.name, event.timestamp_micros
FROM `firebase-analytics-sample-data.android_dataset.app_events_20160607`,
UNNEST(event_dim) as event
WHERE event.name = "round_completed"
-----------------------------------
#standardSQL
SELECT user_dim.user_id, event.name, event.date, event.params, event.timestamp_micros, event.previous_timestamp_micros
FROM `myProjectDatasetName.app_events_20180118`,
UNNEST(event_dim) as event
WHERE
user_dim.user_id = '53156651903'
AND
event.name = 'test'
ORDER BY event.timestamp_micros DESC
-----------------------------------
#standardSQL
SELECT
user_dim.user_id,
user_dim.geo_info.country,
user_dim.geo_info.city,
user_dim.app_info.app_version,
user_dim.app_info.app_platform,
event.date,
event.name,
event.params,
event.timestamp_micros,
event.previous_timestamp_micros
FROM `myProjectDatasetName.app_events_20180118`,
UNNEST(event_dim) as event
WHERE
user_dim.user_id = '5314561903'
AND
event.name = 'test'
ORDER BY event.timestamp_micros DESC
-----------------------------------
回答3:
I also had the same question. I think you can create an application at your end, and authenticate it with OAuth on firebase and query the analytics API
Check this url for javascript application. https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-js
Hope that helps
来源:https://stackoverflow.com/questions/40542637/can-i-get-firebase-analytics-data-using-query