Heisenberg Heisenberg - 2 months ago 14
iOS Question

iOS - Google Analytics screen tracking

I'm using GA to track screen views manually with this code:

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName
value:@"My Screen"];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];


Now, since every instance of "My Screen" loads a content with a dynamic identifier, how can I add this id without using a different screen name? I've read about dimensions and metrics but I don't know if that's appropriate because I can have a lot of identifiers.

Answer

Ok, I found out a solution, using one single dimension ("hit" as scope) and this code:

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName
       value:@"My Screen"];
[tracker send:[[[GAIDictionaryBuilder createScreenView] set:identifier
                                                     forKey:[GAIFields customDimensionForIndex:1]] build]];

In this way, on GA panel, searching for the secondary dimension will display one row for each identifier

Comments