Ben
Ben

Reputation: 109

Tracking user logons through user ID

How do I track all users who have logged in to an web application (database is maintained by external company) using Google Analytics or other services? Yes, I have researched and researched. I am not good a developer and I have the following Google Analytic code to track regular web analytics:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXXXX-2', 'auto');
  ga('send', 'pageview');

</script>

I have a login form and the input id is simply "email". I have a submit button. Please help. Please note that I have looked in to the documentation provided by Google Analytics and I am just simply stupid to comprehend.

Upvotes: 1

Views: 105

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117156

I would recommend you consider taking your email address and encrypting it somehow say MD5 this way you will be able to see unique users against other users with actually sending an Email address to google which you are supposed to do.

Then it is simply a matter of adding the following code to your site and sending the encrypted value as the value for USER_ID

User ID - Web Tracking (analytics.js)

ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' });

Upvotes: 0

nyuen
nyuen

Reputation: 8907

Unfortunately, if you are collecting a users email address through GA, then are you violating the Google Analytics terms of service by collecting personally identifiable information. Please read through this: https://support.google.com/analytics/answer/2795983?hl=en. In particular, it says

The Google Analytics terms of service, which all Google Analytics customers must adhere to, prohibits sending personally identifiable information (PII) to Google Analytics (such as names, social security numbers, email addresses, or any similar data), or data that permanently identifies a particular device (such as a mobile phone’s unique device identifier if such an identifier cannot be reset), even in hashed form. Your Google Analytics account could be terminated and your data destroyed if you use any of this information.

You may need to find another way of tracking users without collecting personal information.

Alternatively, you can use the new User ID feature available through Universal Analyics. https://support.google.com/analytics/answer/3123666?hl=en

Upvotes: 1

Related Questions