gpt4 book ai didi

facebook - 如何使用 Facebook analytics swift 使用 parms 记录自定义事件

转载 作者:行者123 更新时间:2023-12-01 22:20:12 27 4
gpt4 key购买 nike

我知道这是一个基本问题,但我不知道如何使用 Facebook 分析记录带有自定义参数的自定义事件。例如,我想记录以下内容:

  • 播放的歌曲
  • 标题
  • 艺术家

请看下面的代码(不起作用):

    let dict = AppEvent.ParametersDictionary(AppEventParameterName.Custom("title), AppEventParameterName.Custom("artist"))

AppEvent.ViewedContent(contentType: "test", contentId: "test", extraParameters: dict)

我收到错误信息:

“无法使用参数列表‘(AppEventParameterName, AppEventParameterName) 调用‘ParametersDictionary.Type’(又名‘Dictionary.Type’)类型的值”

我也试过:

let dict = AppEvent.ParametersDictionary(AppEventParameterName.Custom("title"), "test") 

如有任何帮助,我们将不胜感激。

最佳答案

如文档中所述,字典的类型必须是 [AppEventParameterName : AppEventParameterValueType]

你可以像这样构建字典:

[.Custom["Song Played]: "Sunday Morning", .Custom["Artist"]: "Maroon 5"]

然后像这样将它输入到 AppEventsLogger 日志调用中:

AppEventsLogger.log("trackedNewSong", parameters: dictionary, valueToSum: nil, accessToken: nil),其中 "trackedNewSong" 是您正在记录的事件,并且您附加到它的参数嵌入在字典中。

希望这对您有所帮助!

关于facebook - 如何使用 Facebook analytics swift 使用 parms 记录自定义事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40732230/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com