4

When a user enters a search query, I'd like to track:

1) Their search term 2) Number of results returned 3) CFUUID

Can someone tell me if all of these parameters can be put into 1 Dictionary or do I need to create a separate Dictionary for every key/value?

Can I do this:

   NSDictionary *flurryDict = 
    [NSDictionary dictionaryWithObjectsAndKeys:searchText,@"Search Term",numResults,@"Results Returned",nil];
    [FlurryAnalytics logEvent:@"USER_SEARCH" withParameters:flurryDict];

Here's what I have so far:

//View Controller
if([searchText length] >=3){


    NSLog(@"Search: %@",searchText);
    NSLog(@"Search Results: %i",[self.filteredListContent count]);
    NSLog(@"Device UUID: %@",[sharedLabelManager myUUID]);

    //Send to Flurry
    NSDictionary *flurryDict = 
    [NSDictionary dictionaryWithObjectsAndKeys:@"Search Term", searchText, nil];
    [FlurryAnalytics logEvent:@"SEARCH" withParameters:flurryDict];




}
Slinky
  • 5,662
  • 14
  • 76
  • 130

1 Answers1

3

Yep. Dictionaries are a set of keys and values, something like below will work just fine:

NSString *uuid = [sharedLabelManaged myUUID];
NSNumber *totalResults = [NSNumber numberWithInt:self.filteredListContent.count];
NSDictionary *flurryDict = [NSDictionary dictionaryWithObjectsAndKeys:searchText, @"SearchTerm", totalResults, @"SearchResultsCount", uuid, @"UUID", nil];

[FlurryAnalytics logEvent:@"SEARCH" withParameters:flurryDict];
Andy Smart
  • 715
  • 1
  • 6
  • 10
  • 1
    Is this ok? The Flurry documentation states that all the values must be NSStrings: http://support.flurry.com/index.php?title=Analytics/GettingStarted/TechnicalQuickStart "Event parameters can be passed in as a NSDictionary object where the key and value objects must be NSString objects. " – Aneil Mallavarapu Feb 28 '13 at 19:46
  • 2
    In the Flurry 4.3 API it's not exclusive to NSString. You can use NSNumbers. [Flurry logEvent:@"Test" withParameters:@{@"Test":@555}]; – bbarnhart Jan 03 '14 at 21:10