How to track how many minutes (or seconds) spends an user on a mobile page?

Hello,

I have an article page and I want to track how many minutes (or seconds) spends an user on this article page on mobile. I want to keep its log. If the user spends 20 seconds, I'll write this seconds to data. Mobile pages have OnDestroy events. I can write data in this event .The hard part is, how can I understand if the user closes the app ? Because I need to write data before he closes the app. I didn't find any solution. 

Thank you for your help.

Emre Ozuslu wrote:

Hello,

I have an article page and I want to track how many minutes (or seconds) spends an user on this article page on mobile. I want to keep its log. If the user spends 20 seconds, I'll write this seconds to data. Mobile pages have OnDestroy events. I can write data in this event .The hard part is, how can I understand if the user closes the app ? Because I need to write data before he closes the app. I didn't find any solution. 

Thank you for your help.

 

 Hi Emre

You can use system events(native system events) if you want to write data before a user closes the application. 

you can find a relevant system event for use here

Hi Shailesh,

Thank you for your reply.
Outsystems mobile has only ready and resume. I think these two does not work.
I found these events which are in the link you provided. I didn't see a specific close event. So do you think pause event can be a solution ?

 Thank you.

Hi Emre

Honestly saying I don't know if it works since I never got a situation like this but I think you should try to implement it once it it doesn't work atleast you have tried it and got to know how it works if it could be of any help in coming future and if it works then voila your problem is solved.

Cheers

 Hi Emre ,

Use onInitialize event on this page and set currdatetime() in local variable also  use onDesroy event and calculate time from local variable and currdatetime and store in DB or show where you want.

Hopw this will help you.

Regards

Rahul Sahu

Rahul Sahu wrote:

 Hi Emre ,

Use onInitialize event on this page and set currdatetime() in local variable also  use onDesroy event and calculate time from local variable and currdatetime and store in DB or show where you want.

Hopw this will help you.

Regards

Rahul Sahu

 Hello Rahul,

I have a query that if a user force closes the mobile application irrespective of screen, does onDestroy event executes? if so then his problem is already solved as per his question and please clarify it will be a new learning fir me.

Thanks

Shailesh wrote:

Rahul Sahu wrote:

 Hi Emre ,

Use onInitialize event on this page and set currdatetime() in local variable also  use onDesroy event and calculate time from local variable and currdatetime and store in DB or show where you want.

Hopw this will help you.

Regards

Rahul Sahu

 Hello Rahul,

I have a query that if a user force closes the mobile application irrespective of screen, does onDestroy event executes? if so then his problem is already solved as per his question and please clarify it will be a new learning fir me.

Thanks

 I dont think so is there any other way . because there is no event for when user force close application and handel it.

https://www.outsystems.com/forums/discussion/44015/how-to-call-a-server-action-when-the-user-kills-the-app/ 

https://stackoverflow.com/questions/679829/firing-event-on-application-close 


Regards

Rahul Sahu

 

Hi Rahul,

Thanks for the insights I will read these documents.

Hi Emre Ozuslu,

I just checked with your requirement and I found that the pause event listener will do the work which you are looking for i.e On Application close the pause event gets triggered


Observation

@Shailesh: I checked and observed that the OnDestory handler didn't got invoked on the application close/kill

- When the application gets to the background and when it brought to the foreground the pause Event get's triggered following the resume event


Supportive Links: https://www.outsystems.com/forums/discussion/33230/onbeforeclose-eventlistener-in-mobile-app#Post115624 

Please find the attached .oml solution file


Hope this helps you!


Regards,

Benjith Sam

Hi Benjith,

Thanks for the efforts I was not sure but just a hint that it could work, so @Emre hope your problem gets solved with this.