Logging custom events in the Firebase Analytics console (Swift)
Asked Answered
A

4

7

I'm trying to log custom events for my location rating app (Swift). After looking through examples it looks like you give attributes a value similar to a JSON database. I still haven't seen the event named logged in the analytics console (it's been about a week).It doesn't have any debug errors. Here is the instance:

FIRAnalytics.logEventWithName("Ratings", Parameters[
    "rating": (indexPath.row + 1)

Any advice?

Accomplished answered 23/9, 2016 at 20:49 Comment(1)
Did you try to turn on the debug mode by using the argument -FIRAnalyticsDebugEnabled? It should show you whether the events were logged successfully.Chlorous
E
15

Its really late but it may help someone

 Analytics.logEvent("Ratings", parameters: [
        "rating" : (indexPath.row + 1)
        ])

FIRAnalytics is replaced with Analytics and logEventWithName is replaced with logEvent

Etamine answered 12/1, 2019 at 8:11 Comment(0)
J
5

The syntax for logging a custom event in Swift would be:

FIRAnalytics.logEventWithName("Ratings", parameters: [
  "rating": (indexPath.row + 1)
])

Make sure that part of your code is getting executed by setting a break-point. Perhaps it's not being run.

Julius answered 23/9, 2016 at 21:53 Comment(1)
Forgot to put that on here, but I did close the arguments there the way you showed. Still am not getting anything.Accomplished
C
3
import FirebaseAnalytics

Example code:

Analytics.logEvent("share_image", parameters: [
  "name": name as NSObject,
  "full_text": text as NSObject,
])
Cambridge answered 8/9, 2022 at 1:23 Comment(0)
I
0

Follow the steps:-

import FirebaseAnalytics

Add the logevent where you want it to trigger (Tested on latest iOS 17),

Analytics.logEvent("Ratings", parameters: ["rating": (indexPath.row + 1)])

Also you can edit the scheme and add argument (-FIRAnalyticsDebugEnabled) to test in debug mode. Go on Firebase -> Analytics dropdown -> Debug View. Here you can map the debug events.:-

PS:- It takes around 24hours or less to reflect on the events.

Intrastate answered 29/7, 2024 at 9:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.