Reputation: 1101
Since the iOS SDK 3.0 of Google Analytics has been released, plenty of changes have been made with the API. There is one big problem we encounter that has to do with the anonymize IP feature.
In Germany one has to anonymize the IPs by law when using some tracking framework. With the previous version of the SDK (2.0) it worked like this:
tracker.anonymize = YES;
where tracker
is an instance of id<GAITracker>
.
Now with the version 3.0 one has to use the set method of the tracker:
[tracker set:kGAIAnonymizeIp value:@"?????"];
The signature of the method is
- (void)set:(NSString *)parameterName
value:(NSString *)value;
and that's the problem. What should the parameter value be? @"YES"
or @"NO"
? @"ON"
or @"OFF"
? @"1"
or @"0"
? Are these parameters case-sensitive?
There is no information about the value
in the documentary. Does anyone know what parameter is correct to anonymize the IPs?
Upvotes: 9
Views: 1314
Reputation: 1045
Update for Google Analytics 4 from its documentation:
In Google Analytics 4, IP anonymization is not necessary since IP addresses are not logged or stored.
Upvotes: 0
Reputation: 1862
[tracker set:kGAIAnonymizeIp value:@"1"];
See the Anonymize IP section of the Google Analytics iOS v3 SDK documentation.
Upvotes: 2
Reputation: 1152
You're getting an error with kGAIAnonymizeIp
because it's defined in GAIFields.h
, which isn't normally imported.
First import the header:
#import "GAIFields.h"
Then set the value:
[tracker set:kGAIAnonymizeIp value:[@YES stringValue]];
Upvotes: 2
Reputation: 3567
I am trying the following method:
[self.tracker set:@"kGAIAnonymizeIp" value:@"YES"];
If I did
[self.tracker set:kGAIAnonymizeIp value:@"YES"];
like in the other answer on here, it gave me an error saying the kGAIAnonymizeIp is an undeclared identifier.
Not sure if what I did works or is even doing anything but at least I tried. The documentation for analytics is really poor.
Upvotes: 0
Reputation: 753
Work for me:
[tracker set:kGAIAnonymizeIp value:[@NO stringValue]];
or
[tracker set:kGAIAnonymizeIp value:[@YES stringValue]];
Upvotes: 3