GA for iOS and custom dimensions

2019-04-14 23:54发布

问题:

We've setup Google Analytics in an iOS app which is sending the vendor identifier to distinguish between users on the reports. Here's what we've done:

In Google Analytics we've setup a Custom Dimension as follows:

Name: User identifier Scope: User Active: True

In the app we add the following in the AppDelegate:

[tracker set:[GAIFields customDimensionForIndex:1] value:uuidString]; // uuidString is the device identifier

In the logging window I can see that the value of cd1 is the correct value yet our custom report shows no data for the custom dimension.

We are using Google Analytics 3.02.

Does anyone have any idea where we are going wrong?

回答1:

Are you sending the tracker?

This is an example from the Custom Dimensions & Metrics for iOS SDK

// May return nil if a tracker has not yet been initialized with a property ID.
id tracker = [[GAI sharedInstance] defaultTracker];

// Set the custom dimension value on the tracker using its index.
[tracker set:[GAIFields customDimensionForIndex:1]
       value:@"Premium user"]

[tracker set:kGAIScreenName
       value:@"Home screen"];

// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once, so it is set on the Map,
// not the tracker.
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"premium"
                                                  forKey:[GAIFields customDimensionForIndex:1]] build]];