Tracking Page Idling

Set up a custom event to track when a user idles on a particular page at your website. Use this custom event to retarget the user with an automated web push notification.

Here are the steps to take to set up tracking page idling at your website:

Step 1: Place the Idle Tracking Code Snippet

The first step is to add the following snippet above your main Aimtell Tracking Script:



<!-- place the following code above the main Aimtell Tracking Script -->
<script>

var _aimtellTimeout;

function _aimtellResetTimer() {
      
      //clear the existing timer
      clearTimeout(_aimtellTimeout);

      //set a new timer for 30 seconds
      _aimtellTimeout = setTimeout(function(){

            //on timeout, track the event with current page
            //add optional variables for personalization of item they went inactive on (e.g. related items, related pages to send them to)
            _at.track("event", {
                  "category" : "Page",
                  "action" : "Inactive",
                  "variables": {
                        "page": window.location.href
                  }
            })
      }, 30000);
}


function _aimtellReady() {
      
      //start or reset timer on mouse move
      document.onmousemove = _aimtellResetTimer;

}
</script>

Note that you can add optional variables for added personalization such as related items or related pages.

Step 2: Check Your Logs

Once you have added the code to your site, we recommend checking your logs to see if the custom event has started to track. Head to Logs > Custom Events to see if it is there. We recommend letting the code run for 24 hours so that you can easily see the events being logged in your dashboard.

Step 3: Create A Triggered Push Campaign

Now it is time to create your triggered push campaign that will send whenever a subscriber activates the trigger which in this case means they have gone inactive on a page. Head to ‘Triggered Campaigns’ from your dashboard and create a new campaign. For your trigger, the Event Category is ‘Page’ and Event Action is ‘Inactive’.

Read our Creating a Triggered Push Campaign documentation for a step-by-step guide on how to do this.

Note: Aimtell will by default only track the same exact event once per session. This will prevent the creation of numerous events if a user were to stay inactive forever, therefore ensuring that the user will not be spammed with tons of notifications.