I've been reading the Custom Dimensions documentation for iOS and found the following example:
// 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]];
But when the dimension is created in control panel, the proposed code is:
NSString *dimensionValue = @"SOME_DIMENSION_VALUE";
[tracker set:[GAIFields customDimensionForIndex:1] value:dimensionValue];
I've been also reading the documentation for Android and found this example:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(TrackerName.APP_TRACKER);
t.setScreen("Home Screen");
// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once.
t.send(new HitBuilders.AppViewBuilder()
.setCustomDimension(1, "premiumUser")
.build()
);
My questions:
The code could be:
[tracker set:[GAIFields customDimensionForIndex:1]
value:@"custom dimension value"]
[tracker send:[[[GAIDictionaryBuilder createAppView] set:@"custom dimension value"
forKey:[GAIFields customDimensionForIndex:1]]
There is a good tutorial how to use custom dimensions both iOS and Android and how to set custom reports.
In the case of the first one there are two different ways. They are independent from each other.
First:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:[GAIFields customDimensionForIndex:index] value:@"value"];
tracker send:[[GAIDictionaryBuilder createScreenView] build]];
Second:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[[GAIDictionaryBuilder createScreenView] set:@"value"
forKey:[GAIFields customDimensionForIndex:index]] build]];
If you want track custom dimensions or custom metric, then you have to create them on the GA adminpage. Here choose custom definitions. After that create a custom report on the customization tab, which will represent your measurements.
Important that you have to wait maybe one or two days after the google analytics registration until measurements will appear in your custom reports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With