4

I need to track user logins so I know how often "UserA" is logging into my site. Can anyone recommend a method to do this? Module or code?

closed as off-topic by kiamlaluno Aug 7 at 5:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking to recommend or find a book, tool, module, theme, distribution, tutorial, or other off-site resource are off-topic for Drupal Answers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

7

I think you are looking for User Stats module.

Provides commonly requested user statistics for themers, IP address tracking and Views integration. Statistics are:

  • days registered;
  • join date;
  • days since last login;
  • days since last post;
  • post count;
  • login count;
  • user online/offline;
  • IP address;
  • Does it give each users logins by date? – dibs May 14 '12 at 8:12
  • 3
    @dibs You can try and check it yourself ;-) – AjitS May 14 '12 at 8:17
  • No. It doesn't ;-) – dibs Sep 19 '12 at 4:49
  • then try this module : drupal.org/sandbox/AshishThakur/1614582 – j2r Sep 20 '12 at 9:05
2

Just to close off this question I will share how I managed to track the user login times.

I simply wrote a module that added a table to the db and on login I would add the login/user event + date-time to the table.

Then I was able to access how many times and at what time users were logging in. This was something I wasn't able to get from the User Stats module.

  • Could you post the code or some elaborate on how you did it? Not sure where to begin w/ doing the same. – jay-ess Oct 6 '15 at 17:36
  • @jay-ess which part don't you understand? Timestamp and UID are recorded to the custom database table on login. This info can then be used to analyse login counts and time patterns for users. – dibs Oct 6 '15 at 18:49
  • k. Will get working on which hooks, etc, and post some code if I can make it work. Thanks. – jay-ess Oct 6 '15 at 19:02
  • You're right, "User stats" is not a solution for your question. But maybe you want to have a look at my answer to this question. If you'd change the "5" in it to eg 9999 (and possibly some other task configuration options), you might be close. – Pierre.Vriens Aug 11 '16 at 17:27
1

use User Track module

A simple module that tracks each time a user logs in and stores a historical record in your database. This data is then exposed to views so you can report on it if required.

Logs minimal data: user ID, and time logged in Ability to exclude users from tracking by role Hooks to allow fine-grained control over which logins get tracked Hooks to allow you to add information to the data stored Views integration

it's available on both Drupal 7, 8

Not the answer you're looking for? Browse other questions tagged or ask your own question.