Search code examples
iosobjective-cgoogle-analyticscampaign-monitor

Google analytics IOS tracking campaigns error No visible @interface for 'GAIDictionaryBuilder' declares the selector 'set:value:'


I am following the instructions contained here https://developers.google.com/analytics/devguides/collection/ios/v3/campaigns#url-builder

Xcode refuses to compile since this statement

[hitParams set:kGAICampaignMedium value:@"referrer"];

gives this error:

No visible @interface for 'GAIDictionaryBuilder' declares the selector 'set:value:'

The same happens to the kGAICampaignSource

I have seen that the "correct" calls may be these two

[hitParams setValue:kGAICampaignMedium forKey:@"referrer"];
[hitParams setValue:kGAICampaignSource forKey:[url host]];

However there is another issue with the call:

[tracker send:[[[GAIDictionaryBuilder createAppView] setAll:hitParams] build]];

Which sends a warning because hitParams should be a NSDictionary and it is a GAIDictionaryBuilder.

Am I doing something wrong? I have upgraded google analytics to the latest (3.10) version.

Thank you all


Solution

  • The specific lines you are having trouble with aren't supported by that version of the SDK. It looks like the v3 SDK documentation is out of date (As at: 2 Dec 2014).

    // hitparams is of type GAIDictionaryBuilder
    [hitParams set:@"referrer" forKey:kGAICampaignMedium];
    [hitParams set:[url host] forKey:kGAICampaignSource];
    
    NSDictionary *paramDictionary = [hitParams build];
    // -setAll: requires an NSDictionary
    [tracker send:[[[GAIDictionaryBuilder createAppView] setAll:paramDictionary] build]];