question

64333888 avatar image
0 Votes"
64333888 asked Monalla-MSFT commented

Unable to track time-on-page in app insights

I have configured app insights using the react-native sdk for my application and I want to enable time-on-page tracking in my application.
As per the documentation we have to set autoTrackPageVisitTime: true. Even after setting that variable as true I'm not getting the duration in app insights.

Anyone has any idea about this issue ?



azure-monitor
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@akshitapandey-2924 - Thanks for reaching out and apologies for the delay in response.

I am looking into this and will get back to you shortly.

1 Vote 1 ·

Ok thanks.

0 Votes 0 ·

1 Answer

Monalla-MSFT avatar image
0 Votes"
Monalla-MSFT answered Monalla-MSFT commented

Hello @64333888 - Thanks for reaching out to us and for being patient.

I understand that you are trying to set autoTrackPageVisitTime to true, and even after setting it, you still dont see the duration in AI.

Can you please ensure that you are looking at the right spot, because the previous instrumented page's view time is tracked and sent as telemetry and a new timer is started for the current pageview. It's sent as a custom metric named PageVisitTime in milliseconds and is calculated via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less). Default is false.


Please let me know if you are still having issues and we can look into it further.

Hope this helps. and please feel free to reach out if you have any further questions.



If the above response was helpful, please feel free to "Accept as Answer" and "Upvote" the same so it can be beneficial to the community.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Monalla-MSFT,
I have re-checked the code but still I'm unable to capture the PageVisitTime.

Please find the code snippet below.

 export const appInsightsEventInfo = (eventname: string) => {
     const RNPlugin = new ReactNativePlugin();
     const appInsights = new ApplicationInsights({
       config: {
         instrumentationKey: 'xxx-xxx',
         extensions: [RNPlugin],
         autoTrackPageVisitTime: true
       },
     });
       appInsights.loadAppInsights();
     appInsights.trackEvent({name: eventname});
 }

I'm using this query to fetch the logs : customMetrics | order by timestamp



0 Votes 0 ·