Reputation: 11
I am trying to implement user_ID tracking in analytics under the ".js" feature. Can someone help with assigning a "unique, persistent, and non-personally identifiable string ID" to an existing user of my google site.
For the sake of the argument, the existing user has the following fictional email address registered with my google site: [email protected]
I have already checked user_ID related queries but no specific answer
Upvotes: 1
Views: 541
Reputation: 1529
User ID is something unique stored on your server/database related to email or phonenumeber or whatever identifying.
You need to have some anonymouse string internally related to real user, but publicly you send only anonymouse string - the User ID.
Some macro in your template or CMS have tu join Javascript Unioversal Analytics configuration snippet:
As Eike Says:
ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });
Where USER_ID is macro of your template system returning that anonymouse string.
Upvotes: 1
Reputation: 32780
It's rather unclear what you mean by "the .js feature".
For the user id, you have to generate this serverside and store it along with the user data (you cannot store this on the client side via cookies or the like, since this won't work for users who clear their cookies or visit the site with different devices).
Apart from that it doesn't matter that much which format you use for the userid - this might be the hashed/encrypted email address, or a random number, or the millisecond at which the user registered. The important thing is that is must not be possible to recognize the user from the id (except for yourself by matching it to a stored record on the server).
You pull the id from the server and pass it to Analytics via Javascript
ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });
You need to create a special userid view which will only show data from authenticated users.
Upvotes: 0