当我使用Objective-c
作为编码语言时,谷歌分析正在正确地发送数据,但当谈到swift
时,我非常混乱。它没有发送任何命中。由于我没有使用cocoapods
依赖项,所以我导入了以下文件: -
GAI.h
GAIDictionaryBuilder.h
GAIEcommerceProduct.h
GAIEcommerceProductAction.h
GAIEcommercePromotion.h
GAIFields.h
GAILogger.h
GAITrackedViewController.h
GAITracker.h
我正在导入以下框架: -
CoreData.framework
SystemConfiguration.framework
libz.dylib
libsqlite3.dylib
libGoogleAnalyticsServices.a
我的App-delegate代码是:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
GAI.sharedInstance().trackUncaughtExceptions = true //tracking exception
GAI.sharedInstance().dispatchInterval = 20 //time interval for sending data
GAI.sharedInstance().trackerWithTrackingId("UA-xxxxxxx-1") //Tracking id
GAI.sharedInstance().logger.logLevel = GAILogLevel.Verbose
//For getting verbal messages in console
}
我的屏幕跟踪代码是: -
let tracker = GAI.sharedInstance().defaultTracker
tracker.setValue(kGai, forKey: "Tab4")
tracker.send(GAIDictionaryBuilder.createScreenView().build)
我在控制台中记录的日志是: -
2016-07-18 13:57:46:394 App_GA[11685:1073352] Verbose
2016-07-18 13:57:46:395 App_GA[11685:1073352] Debug
2016-07-18 13:57:46:395 App_GA[11685:1073352] Info
2016-07-18 13:57:46:396 App_GA[11685:1073352] Warn
2016-07-18 13:57:46:396 App_GA[11685:1073352] Error
documentPath ::Optional("/var/mobile/Containers/Data/Application/26EC3AF9-9D88-4D9F-88AC-7CE0F6D0F93D/Documents")
setup ::nil, device::nil
success
请帮忙!