I know this a basic question, but I can't work out how to log a custom event with custom parameters using facebook analytics. For example, I would like to log the following:
Please see the below code (which does not work):
let dict = AppEvent.ParametersDictionary(AppEventParameterName.Custom("title), AppEventParameterName.Custom("artist"))
AppEvent.ViewedContent(contentType: "test", contentId: "test", extraParameters: dict)
I get the error message:
"Cannot invoke value of type 'ParametersDictionary.Type' (aka 'Dictionary.Type') with argument list '(AppEventParameterName, AppEventParameterName)"
I have also tried:
let dict = AppEvent.ParametersDictionary(AppEventParameterName.Custom("title"), "test")
Any help would be greatly appreciated.
As mentioned in the documentation, the dictionary needs to be of type [AppEventParameterName : AppEventParameterValueType]
.
You can construct the dictionary like:
[.Custom["Song Played]: "Sunday Morning", .Custom["Artist"]: "Maroon 5"]
Then just input it into the AppEventsLogger log call like this:
AppEventsLogger.log("trackedNewSong", parameters: dictionary, valueToSum: nil, accessToken: nil)
, where "trackedNewSong"
would be the event you are logging and the parameters you are attaching to it are embedded in the dictionary.
Hope this helps!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments