Closed. This question needs to be more focused. It is not currently accepting answers.admin管理员组文章数量:1435859
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 questionI 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 questionI 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
1 Answer
Reset to default 1You 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.
本文标签: pluginsSave user total active time after login in wordpress
版权声明:本文标题:plugins - Save user total active time after login in wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745615326a2666365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论