How to use a variable in Google Analytics' Custom Variable,iOS

Thursday, July 3, 2014

I have a question regarding tracking a single user by username where user logged in the login page.

I need of a tracking which users are logging in. I would be able to see that user name in GA. I know Google Analytics offers this kind of tracking using custom variables, but I can't see the user Name in shows only the Assigned and NonAssigned name in the GA.

So what I am looking to do is track usernames and the page they visit on the page, can this be done using custom variables, and does it violate GA privacy policy? is there any sample code for this ?

I used this code for custom variable

//////********** method for get userid

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

// You only need to set User ID on a tracker once. By setting it on the tracker, the ID will be
// sent with all subsequent hits.
[tracker set:@"&uid"
value:email.text]; //here I pass the custom value as the user email adders

// This hit will be sent with the User ID value and be visible in User-ID-enabled views (profiles).
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"UX" // Event category (required)
action:@"User Sign In" // Event action (required)
label:nil // Event label
value:nil] build]];

[tracker set:[GAIFields customDimensionForIndex:1] value:email.text];

////////******** methoid for get user id