How can I log every button click in iOS App with Flurry? I want to realize click flows in my app.
Asked
Active
Viewed 265 times
-1
-
You do realize that you're app's performance is going to be seriously affected by doing that? – Richard Brown Apr 10 '13 at 02:42
2 Answers
1
In AppDelegate
#import "Flurry.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Flurry startSession:@"sessionkey"];
...
}
and..
-(IBAction) Click_Search:(id)sender
{
[Flurry logEvent:@"Seach"]; // remain logEvent
...
}

ash84
- 787
- 3
- 12
- 33
1
A valid approach would be to subclass UIApplication
and overwrite the -sendEvent:
method
like follows:
- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
NSSet * allTouches = [event allTouches];
if ([allTouches count] > 0) {
UITouch *touch = [allTouches anyObject];
if (touch.phase == UITouchPhaseBegan) {
CGPoint touchLocation = [touch locationInView:touch.window];
NSDictionary *params = @{
@"touch" : @{
@"x" : @(touchLocation.x),
@"y" : @(touchLocation.y)
}
};
[Flurry logEvent:@"Seach" withParameters:params];
}
}
}
Then you just need to change the UIApplication
class to be used in main.m
.
For instance if your UIApplication
subclass is called MyApplication
, your main will become
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyApplication class]));
}
}
DISCLAIMER
This may drastically affect the performance of your app. Use it wisely.

Gabriele Petronella
- 106,943
- 21
- 217
- 235