kGAIScreenName of Google Analytics for iOS v3 is u

2019-02-11 10:14发布

Today, I found GoogleAnalytics-iOS-SDK have new 3.0 version in Cocoapods. I upgraded and I try to modified the code of manual screen measurement as below:

id tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:@"Detail View"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];

However, I always get error about kGAIScreenName is undeclared. Even I add GAIFields.h header, it still not work.

What did I miss?

2条回答
贼婆χ
2楼-- · 2019-02-11 10:39

I am using a hardcoded value of @"&cd" for kGAIScreenName and it works perfectly. Found the value in the Measurement Protocol documentation at Google https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#apptracking

查看更多
小情绪 Triste *
3楼-- · 2019-02-11 10:40

You have to include two more things:

#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"

Checking what's in GAIFields.h I can see that kGAIScreenName is there:

extern NSString *const kGAIScreenName;   // synonym for kGAIDescription

Might be important point that the current Google Analytics is in beta, so using the latest downloadable SDK is always a good idea. What I tried and what is working currently for me is Version: 3.0 (August 16, 2013).

查看更多
登录 后发表回答