我对iOS应用中的Google Analytics广告系列有一些疑问。据我了解,它提供了用户访问应用程序(安装或启动)的信息 - 通过广告活动,网站或其他应用程序的推介。那是对的吗?我正在使用以下代码here是否足以实现此结果或我遗漏了一些内容:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let urlString = url.absoluteString
let tracker = GAI.sharedInstance().tracker(withName: "tracker", trackingId: "<MyTrackingID>")
let hitParams = GAIDictionaryBuilder()
hitParams.setCampaignParametersFromUrl(urlString)
if (!(hitParams.get(kGAICampaignSource) != nil) && ((url.host?.count)! > 0)) {
hitParams.set("referrer", forKey: kGAICampaignMedium)
hitParams.set(url.host, forKey: kGAICampaignSource)
}
let hitParamsDictionary = hitParams.build()
//check if the following is needed
tracker?.set(kGAIScreenName, value: "Default Name")
tracker?.send(GAIDictionaryBuilder.createScreenView().setAll(hitParamsDictionary as! [AnyHashable : Any]).build() as! [AnyHashable : Any]!)
return true
}
我也有这个设置,我将GoogleIDFASupport Cocoapod添加到Podfile。这是安装跟踪所需要的吗?:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
let tracker = gai.tracker(withTrackingId: "<MyTrackingID>")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true
tracker?.allowIDFACollection = true
// Optional: set Logger to VERBOSE for debug information.
// Remove before app release.
gai.logger.logLevel = .verbose;
return true
}