Tip of the Week: How to ensure PX sessions are consistent with your web application's sessions in PX Analytics

  • 28 January 2020
  • 2 replies

Userlevel 6

Hi All!


While working with our PX customers to build awesome custom PX Dashboards, we tend to spend some time explaining what a “PX session” is and how we calculate it for the “Average session duration”,  “Session count”, and “Session per country” Dashboard widgets. See below:


For those that need a refresher or do not know, here is what a PX “session” is…

PX sessions are calculated based on application usage activity tracked by PX and are independent of your application's session settings or logins/logouts.  

A PX session starts with the first event tracked for a user and ends when 30 minutes of inactivity occurs (PX has not seen/tracked any activity for that user).  

The next event that PX tracks for this same user … whether it is 31 minutes from the last event or the very next hour or day … starts a new PX session.

Users can and will have multiple PX sessions per day depending on how often a 30 minute window of inactivity occurs for them.


Additionally, here is how PX session “duration” is calculated …

PX session "duration" is calculated using the elapsed time between the first tracked event for a user and the last tracked event for that user within a single continuous PX “session”.

Some PX session "durations" can be recorded in seconds or minutes or even hours depending on how active the user was while PX was tracking their events within a single PX session.


With those items out of the way, now let me move on to the point of this Tip of the Week...


Most all of our PX customers have a specific web application session timeout configured and it does not match with our PX session’s 30 minute timeout setting.  As a result, the number of recorded PX sessions (a.k.a. “visits”) shown in PX Analytics is usually not identical to the number of recorded web application sessions in other analytics applications they may use such as Google Analytics.

Currently, there is not any way to increase/decrease the PX Session setting in our PX application to match whatever your web application’s session setting may be, so there needs to be another way. 


I am happy to report that there is a way and I will describe it below…



Customers need a way to make their Application Sessions/Visits match with PX Sessions/Visits without changing their Application session timeout setting to be 30 minutes.

Recommended Solution (requires your web application developer’s assistance):

To ensure that a PX session remains open as long as needed, use our Custom Events API to issue a track custom event call at least every 25 minutes.  It can be at minute 29, but having a little “buffer room” seems to be a good best practice recommendation. 

Here is some sample PX Custom Event JavaScript that can be used in your web application to keep the PX session “alive”, but do make this your own:

//Custom Events API Javascript code
var myVar = window.setInterval(myTimer, 1500000); // 25 minutes
function myTimer() {
  window.aptrinsic(‘track’,’Keep PX session alive’,);
//end Custom Events API Javascript code

As a result of the above JavaScript code, the PX session will remain Active as long as the customers’ web application session is active … and making the JavaScript call to that “keep alive” Custom Event.


And lastly, our PX engineering team has recently introduced a new JavaScript method called “reset” to end the current PX session for a user.   Here is some sample JavaScript code that you can consider using in your web application:

//Close PX Session Javascript code
window.aptrinsic('reset’); // Closes current PX Session
//End Close PX Session Javascript code

A good place to consider using this “reset” JavaScript call would be during your web application’s “logout” process to align the PX session “end” with your application’s session “end”.  Of course, the next time a user logs into your web application a new PX session will begin.


That is all for now, but we would love to hear your feedback about this and our many other excellent PX Community discussion topics.


Happy PX-ing! :)



2 replies

Userlevel 5

How creative!!

Userlevel 3

Excellent tip! Tnx :)