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:
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"
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];
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.
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.
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
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