first_open
in_app_purchase
func recordGameOver() { let tracker = GAI.sharedInstance().defaultTracker let gameOverEvent = GAIDictionaryBuilder.createEvent(withCategory: "gameOver", action: "totalScore", label: "", value: myGameStats.totalScore as NSNumber) let enemiesBeatenEvent = GAIDictionaryBuilder.createEvent(withCategory: "gameOver", action: "enemiesBeaten", label: "", value: myGameStats.enemiesBeaten as NSNumber) let roundsSurvivedEvent = GAIDictionaryBuilder.createEvent(withCategory: "gameOver", action: "roundsSurvived", label: "", value: myGameStats.roundsSurvived as NSNumber) tracker?.send(gameOverEvent.build() as [NSObject: AnyObject]) tracker?.send(enemiesBeatenEvent.build() as [NSObject: AnyObject]) tracker?.send(roundsSurvivedEvent.build() as [NSObject: AnyObject]) }
FIRAnalytics.logEvent(withName: "gameOverTotalScore", parameters: [kFIRParameterValue: myGameStats.totalScore as NSObject]) FIRAnalytics.logEvent(withName: "gameOverEnemiesBeaten", parameters: [kFIRParameterValue: myGameStats.totalScore as NSObject]) FIRAnalytics.logEvent(withName: "gameOverTotalScore", parameters: [kFIRParameterValue: myGameStats.totalScore as NSObject])
let finalStats = ["totalScore": myGameStats.totalScore as NSObject, "enemiesBeaten": myGameStats.enemiesBeaten as NSObject, "roundsSurvived": myGameStats.roundsSurvived as NSObject] FIRAnalytics.logEvent(withName: "gameOver", parameters: finalStats)
GoogleService-info.plist
GoogleService-info
TRACKING_ID
func recordGameOver() { // All the old code you had previously to record Google Analytics // … // … So much code … // … // Now add the Firebase stuff let finalStats = ["totalScore": myGameStats.totalScore as NSObject, "enemiesBeaten": myGameStats.enemiesBeaten as NSObject, "roundsSurvived": myGameStats.roundsSurvived as NSObject] FIRAnalytics.logEvent(withName: "gameOver", parameters: finalStats) }
func recordGameOver() { let finalStats = ["totalScore": myGameStats.totalScore as NSObject, "enemiesBeaten": myGameStats.enemiesBeaten as NSObject, "roundsSurvived": myGameStats.roundsSurvived as NSObject] FIRAnalytics.logEvent(withName: "gameOver", parameters: finalStats) // That's it! }
SELECT AVG(hit.eventInfo.eventValue) FROM `my_awesome_app.ga_sessions_20170123`, UNNEST(hits) AS hit WHERE hit.eventInfo.eventCategory = "gameOver" AND hit.eventInfo.eventAction = "totalScore"
SELECT COUNT(*), AVG(total_score) AS average FROM ( SELECT event_param.value.int_value AS total_score FROM `firebase-project.com_example_awesome_app.app_events_20170123`, UNNEST(event_dim) AS event, UNNEST(event.params) AS event_param WHERE event.name = "gameOver" AND event_param.key = "totalScore" UNION ALL SELECT hit.eventInfo.eventValue AS total_score FROM `my_awesome_app.ga_sessions_20170123`, UNNEST(hits) AS hit WHERE hit.eventInfo.eventCategory = "gameOver" AND hit.eventInfo.eventAction = "totalScore" )
FIRAnalytics.logEvent(withName: "workout_complete", parameters: [ "time": 1804 "exercise_type": "interval" "intensity": 2 ])
FIRAnalytics.logEvent(withName: "workout_complete", parameters: [ "time": 1804 "exercise_type": "interval" "intensity": 2 kFIRParameterValue: 1804 ])
workout_complete
invite_friends
eat_meal
app_events_intraday
SELECT user_dim.app_info.app_instance_id, user_dim.device_info.device_category, user_dim.device_info.user_default_language, user_dim.device_info.platform_version, user_dim.device_info.device_model, user_dim.geo_info.country, user_dim.geo_info.city, user_dim.app_info.app_version, user_dim.app_info.app_store, user_dim.app_info.app_platform FROM [firebase-analytics-sample-data:ios_dataset.app_events_20160601]
user_dim.app_info.app_instance_id
UNION ALL
SELECT user_dim.geo_info.country as country, EXACT_COUNT_DISTINCT( user_dim.app_info.app_instance_id ) as users FROM [firebase-analytics-sample-data:android_dataset.app_events_20160601], [firebase-analytics-sample-data:ios_dataset.app_events_20160601] GROUP BY country ORDER BY users DESC
user_properties
SELECT user_dim.user_properties.value.value.string_value as language_code, EXACT_COUNT_DISTINCT(user_dim.app_info.app_instance_id) as users, FROM [firebase-analytics-sample-data:android_dataset.app_events_20160601], [firebase-analytics-sample-data:ios_dataset.app_events_20160601] WHERE user_dim.user_properties.key = "language" GROUP BY language_code ORDER BY users DESC
SELECT event_dim.name, COUNT(event_dim.name) as event_count FROM [firebase-analytics-sample-data:android_dataset.app_events_20160601] GROUP BY event_dim.name ORDER BY event_count DESC
SELECT event_dim.params.value.int_value as virtual_currency_amt, COUNT(*) as num_times_spent FROM [firebase-analytics-sample-data:android_dataset.app_events_20160601] WHERE event_dim.name = "spend_virtual_currency" AND event_dim.params.key = "value" GROUP BY 1 ORDER BY num_times_spent DESC
SELECT user_dim.geo_info.city, COUNT(user_dim.geo_info.city) as city_count FROM TABLE_DATE_RANGE([firebase-analytics-sample-data:android_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()), TABLE_DATE_RANGE([firebase-analytics-sample-data:ios_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()) GROUP BY user_dim.geo_info.city ORDER BY city_count DESC
SELECT user_dim.app_info.app_platform as appPlatform, user_dim.device_info.device_category as deviceType, COUNT(user_dim.device_info.device_category) AS device_type_count FROM TABLE_DATE_RANGE([firebase-analytics-sample-data:android_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()), TABLE_DATE_RANGE([firebase-analytics-sample-data:ios_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()) GROUP BY 1,2 ORDER BY device_type_count DESC
user_dim.user_id
SELECT STRFTIME_UTC_USEC(eventTime,"%Y%m%d") as date, appPlatform, eventName, COUNT(*) totalEvents, EXACT_COUNT_DISTINCT(IF(userId IS NOT NULL, userId, fullVisitorid)) as users FROM ( SELECT fullVisitorid, openTimestamp, FORMAT_UTC_USEC(openTimestamp) firstOpenedTime, userIdSet, MAX(userIdSet) OVER(PARTITION BY fullVisitorid) userId, appPlatform, eventTimestamp, FORMAT_UTC_USEC(eventTimestamp) as eventTime, eventName FROM FLATTEN( ( SELECT user_dim.app_info.app_instance_id as fullVisitorid, user_dim.first_open_timestamp_micros as openTimestamp, user_dim.user_properties.value.value.string_value, IF(user_dim.user_properties.key = 'user_id',user_dim.user_properties.value.value.string_value, null) as userIdSet, user_dim.app_info.app_platform as appPlatform, event_dim.timestamp_micros as eventTimestamp, event_dim.name AS eventName, event_dim.params.key, event_dim.params.value.string_value FROM TABLE_DATE_RANGE([firebase-analytics-sample-data:android_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()), TABLE_DATE_RANGE([firebase-analytics-sample-data:ios_dataset.app_events_], DATE_ADD('2016-06-07', -7, 'DAY'), CURRENT_TIMESTAMP()) ), user_dim.user_properties) ) GROUP BY date, appPlatform, eventName