plugins - Save user total active time after login in wordpress

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Upd

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

I want to calculate the total active time of the user after user login in wordpress site.

For this i am using the following hook in my custom plugin:

add_action('wp_login', 'save_login_time', 10, 2); 

Here i want to check weather the user is active(by mouse events and keypress events) or not.

If user is active, i want to calculate the time and if the time is greater than 2 minutes then i want to store that time details and save the data in another table.

I have no idea how i can put jquery on perticular hook.

I want you to give me an overview that how can i do this functionality in my site?

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

I want to calculate the total active time of the user after user login in wordpress site.

For this i am using the following hook in my custom plugin:

add_action('wp_login', 'save_login_time', 10, 2); 

Here i want to check weather the user is active(by mouse events and keypress events) or not.

If user is active, i want to calculate the time and if the time is greater than 2 minutes then i want to store that time details and save the data in another table.

I have no idea how i can put jquery on perticular hook.

I want you to give me an overview that how can i do this functionality in my site?

Share Improve this question asked Apr 8, 2019 at 9:49 Wordpress LearnerWordpress Learner 1092 bronze badges 2
  • Please some one can give overview about this. – Wordpress Learner Commented Apr 8, 2019 at 10:26
  • Read up on setting up AJAX action hooks. – bosco Commented Apr 9, 2019 at 19:04
Add a comment  | 

1 Answer 1

Reset to default 1

You will want to use either a serverside method, adding a function or hook each time the user loads a page. The first time you check, you can set a cookie or session variable containing a timestamp to start the "active time" on the site. Each time they load a page, you can test for this variable and then using the current time to determine the total time spent on the site. The problem would be knowing when the active time ends.

The other option is to use JavaScript, if you really want to trigger it using mouse and key events. You can add a listener for keyup or mousemove for example which trigger a callback to update the time on site. You can then use an onbeforeunload event to update the time spent on the page.

A better option in my view is to use something like Google Analytics to track user engagement on your site. Another option is user tracking from HotJar.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745615327a4636200.html

相关推荐

  • plugins - Save user total active time after login in wordpress

    Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Upd

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信