Guy*_*y S 6 google-analytics ios
我想将Google Analytics 的"常规广告系列和流量来源归因"选项添加到我的iOS应用中.
我添加了GA SDK(不是pod文件):
(我没有添加libAdIdAccess.a lib)
并添加了屏幕跟踪,它工作正常.
然后我将以下代码(从上面附带的链接)添加到我的AppDelegate.m
// For iOS 9.0 and later
- (BOOL)application:(UIApplication *)app openURL:(nonnull NSURL *)url
options:(nonnull NSDictionary<NSString *,id> *)options {
NSString *urlString = [url absoluteString];
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithName:@"tracker"
trackingId:@"UA-XXXX-Y"];
// provided correcrt trackingId (works for screen tracking)
// setCampaignParametersFromUrl: parses Google Analytics campaign ("UTM")
// parameters from a string url into a Map that can be set on a Tracker.
GAIDictionaryBuilder *hitParams = [[GAIDictionaryBuilder alloc] init];
// Set campaign data on the map, not the tracker directly because it only
// needs to be sent once.
[hitParams setCampaignParametersFromUrl:urlString];
// Campaign source is the only required campaign field. If previous call
// did not set a campaign source, use the hostname as a referrer instead.
if(![hitParams get:kGAICampaignSource] && [url host].length !=0) {
// Set campaign data on the map, not the tracker.
[hitParams set:@"referrer" forKey:kGAICampaignMedium];
[hitParams set:[url host] forKey:kGAICampaignSource];
}
NSDictionary *hitParamsDict = [hitParams build];
// A screen name is required for a screen view.
//[tracker set:kGAIScreenName value:@"screen name"];
// Previous V3 SDK versions.
// [tracker send:[[[GAIDictionaryBuilder createAppView] setAll:hitParamsDict] build]];
// SDK Version 3.08 and up.
//[tracker send:[[[GAIDictionaryBuilder createScreenView] setAll:hitParamsDict] build]];
[tracker send:hitParamsDict];
}
Run Code Online (Sandbox Code Playgroud)
如何测试它是否有效,应用程序是否会成功将引荐来源信息发送给GA?
是否有类似iOS的测试?
还有一个问题,只是为了确保我理解正确,如果我只对一般广告系列和流量来源归因感兴趣,而不是iOS安装广告系列测量,那么我不需要libAdIdAccess.a从sdk 添加lib,请检查iOS广告系列跟踪是开启还是使用IDFA,对吗?
谢谢