Google Analytics for iOS – Sending Custom Event Data using Dictionaries as createEventWithCategory allows only 4 parameters to be sent

I decided to use Google Analytics over Flurry, as Flurry stopped updating tracking Events and nobody from Flurry Support team replied to my query. My requirement is as follows:

  • “Whenever user clicks on tab I need to create an event which includes Tab Name, User ID, Time Stamp.” A screenshot from Flurry Event log may describe it more clearly.

Flurry Event Log

  • Google Analytics not initialising in Swift
  • Google Analytics in iOS (Not Working)
  • How to disable/remove FirebaseAnalytics
  • Can't find headers for GoogleAnalytics-iOS-SDK with Cocoapods 0.37, Swift, frameworks
  • How to get active users distributed by Campaign source? Google Analytics campaign tracking ios
  • 'ErrorType' is not convertible to 'NSError'
  • So, in Google Analytics Event Tracking function createEventWithCategory almost does the needful but it does not allow me to add my custom parameters like User ID, Time Stamp.

    [tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action"     // Event category (required)
                                                      action:@"button_press"  // Event action (required)
                                                       label:@"play"          // Event label
                                                       value:nil] build]];    // Event value

    I tried for two solutions and neither of them are upto my expectation which brings me with two questions regarding each approach I took:

    Attempt 1: Custom Dimensions:

    Documentation has a sample code like this :

    // 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]];

    [Custom dimension values can be sent with any Google Analytics hit type, including screen views, events, ecommerce transactions, user timings, and social interactions.]

    So, I decided to use custom dimensions with createEventWithCategory method and ended up doing like as follows **which works but does not show data as Flurry showed. **

     NSString *dimensionValue = @"USER_ID";
    [tracker set:[GAIFields customDimensionForIndex:1] value:dimensionValue];
    [tracker send:[[[GAIDictionaryBuilder createEventWithCategory:@"TAB_CLICK"
                                                               action:@"Tab Hit"
                  set:currentUserEmail forKey:[GAIFields customDimensionForIndex:1]] build]];

    GA Custom Dimension

    Attempt 2: Setting and Sending Data using Dictionaries:

    I followed the documentation and tried sending NSDictionary object to - (void)send:(NSDictionary *)parameters;method declared in GAITracker.h.

    But I have no clue where this data will appear in dashboard. Neither in Behavior not in Real Time it shows any update.

     id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-X"]; 
     NSDictionary *dataToSendGoogleAnalytics = [NSDictionary dictionaryWithObjectsAndKeys:currentTime,@"TIME_STAMP",clickedTabName,@"TAB_NAME", currentUserEmail, @"USER_ID",nil];   
     [tracker send:dataToSendGoogleAnalytics];

    Question: Can’t I use something straightforward as Flurry which will give me result like in image and allow me to have event parameters like USER_EMAIL, Time_Stamp, TAB_NAME altogether with every event?:

    Flurry Event

    Using simple function like this which accepts NSDictionary object?

    [Flurry logEvent:@"TAB_CLICKED" withParameters:dataToSendFlurry timed:YES];

    Any suggestions or hint would be appreciated. Thank you.

    3 Solutions Collect From Internet About “Google Analytics for iOS – Sending Custom Event Data using Dictionaries as createEventWithCategory allows only 4 parameters to be sent”

    you can send custom data to google analytics by using custom dimension.

    you need to add custom dimension from your dashboard
    after adding that you will get the code..

    Just integrate that in your project and follow below link to see the values.
    enter image description here

    I never used custom parameters with GA, anyway I think this can help you.

    1. Open your Analytics in Behavior/Top Events.

    Behavior/Top Events

    1. Select any primary dimension and click over Secondary Dimension.

    Secondary Dimension

    1. Click over Custom Variables to expand it.

    Custom Variables

    1. Finally, select the variables your want to analise.

    Custom Variables

    Now there is another solution for Google users.

    There is another solution since Google set Firebase as a default for mobile application solution.

    Firebase is Google’s mobile app developer platform and helps developers incorporate Google’s mobile app services quickly and easily – including Google Analytics.

    Here is how Google Analytics changed the way of adding new property under Analytics admin page:

    enter image description here

    You can use Firebase send events like how in Flurry.

    Try this method to send events:

    [FIRAnalytics logEventWithName:kFIREventSelectContent
                                     kFIRParameterItemID:[NSString stringWithFormat:@"id-%@", self.title],

    There is no limit on the total volume of events your app logs.

    View events in the dashboard

    You can view aggregrated statistics about your Analytics events in the Firebase console dashboards. These dashboards update periodically throughout the day. For immediate testing, use the debug console output as described in the previous section.

    You can access this data in the Firebase console as follows:

    1. In the Firebase console, open your project.
    2. Select Analytics from the menu to view the Analytics reporting dashboard.

    The Events tab shows the event reports that are automatically created for each distinct type of Analytics event logged by your app. Read more about the Analytics reporting dashboard in the Firebase Help Center.

    You can add Firebase using cocoapods. Add the dependency for Firebase to your Podfile:

    pod 'Firebase/Core'

    Run pod install and open the created .xcworkspace file.

    Import the Firebase module in your UIApplicationDelegate subclass:

    import Firebase

    Configure a FIRApp shared instance, typically in your application’s application:didFinishLaunchingWithOptions: method:

    // Use Firebase library to configure APIs