Question: I was using Google Analytics API v2 and it was working great. When a user open my app, it will show up on the real time analysis and if the user quits the app, that user was not showing up anymore on that report. That took it around 20 or 30 seconds.

But using the new session management suggested by Google on the Analytics API v3, it took almost 3 minutes for a user to disappear from the real time report after quitting my app.

This is the code that I'm using when launching my app:

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
....
[GAI sharedInstance].trackUncaughtExceptions = NO;

// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;

// Initialize tracker.
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"XX-YYYYYYYY-Z"];

[tracker set:kGAISessionControl value:@"start"];
}

```

And this is the code to end analytics session:

```
- (void)applicationWillResignActive:(UIApplication *)application
{
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"XX-YYYYYYYY-Z"];

[tracker set:kGAISessionControl value:@"end"];
}

```

Is this code correct? Am I missing something?

Answer: 
Not sure if it is the best solution or even if you can control this, but it may work if you do double-encoding: for example, instead of "%23", make it use "%2523".

The unwanted decoding should then convert "%2523" to "%23", leaving the desired result in the redirect URL that the browser shows.
You need to URI-escape the "#" character.