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.
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:
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"
label:clickedTabName
value:nil]
set:currentUserEmail forKey:[GAIFields customDimensionForIndex:1]] build]];
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?:
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.
you can send custom data to google analytics by using custom dimension.
Just integrate that in your project and follow below link to see the values.
http://www.lunametrics.com/blog/2013/09/10/access-custom-dimensions-google-analytics/#sr=g&m=o&cp=or&ct=-tmc&st=hpphmf%20dvtupn%20ejnfotjpo&ts=1384845402
I never used custom parameters with GA, anyway I think this can help you.
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:
You can use Firebase send events like how in Flurry.
Try this method to send events:
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:
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:
Run
pod install
and open the created .xcworkspace file.Import the Firebase module in your UIApplicationDelegate subclass:
Configure a FIRApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method: