我想将Google Analytics的"General Campaign & Traffic Source Attribution"选项添加到我的iOS应用中。
我添加了GA SDK(不是pod文件):
(我没有添加libAdIdAccess.a lib)
并添加了屏幕跟踪,效果很好。
然后我将以下代码(from the attached link above)添加到我的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];
}
如何测试它是否有效,应用程序是否会成功将引荐来源信息发送给GA?
iOS上有类似this test的内容吗?
还有一个问题,只是为了确保我理解正确,
如果我只对General Campaign & Traffic Source Attribution而不是iOS install campaign measurement感兴趣,那么我不需要从sdk添加libAdIdAccess.a
lib,请检查iOS广告系列跟踪是否为ON或使用IDFA,对吗?
谢谢