Skip to main content
Skip table of contents

Page Navigation Events - Optimizing Data Tracking on Page Unload

Tracking user interactions on a website is crucial for understanding user behavior and improving overall user experience. One of the key challenges in tracking is ensuring that data is captured accurately during page unload events, such as when a visitor clicks a link to navigate to another page. This article discusses best practices for optimizing data tracking during these events, the common challenges developers face in this context and how we at JENTIS provide fast track solutions that optimize your data.

Page unload events are significant because they represent a moment when the user is transitioning away from the current page. Capturing data during this transition allows businesses to gather insights into user behavior, such as:

  • Understanding Navigation Patterns: Knowing which links users click can help identify popular content and navigation paths.

  • Identifying Conversion Metrics: Tracking actions leading to conversions can help refine marketing strategies and improve user engagement.

  • Detecting Abandonment: Monitoring which users leave without completing desired actions can inform strategies to reduce drop-off rates.

While optimizing tracking on page unload events can enhance data collection, several challenges may arise:

  1. Timing Issues: If the tracking code takes too long to execute, it may not complete before the page unloads. Using asynchronous methods like sendBeacon can mitigate this issue, but careful coding is still essential.

  2. Browser Differences: Different browsers may handle unload events and JavaScript execution differently. Testing across multiple browsers is crucial to ensure consistent behavior.

  3. Network Latency: If the network is slow or if there are connectivity issues, there might be a risk of losing tracking data. The sendBeacon method helps with this, but it's important to monitor and optimize network performance.

  4. User Experience: Excessive tracking or poorly implemented listeners can degrade user experience. Make sure that tracking scripts do not interfere with normal navigation or lead to noticeable delays.

  5. Single Page Applications (SPAs): In SPAs, traditional page unload events may not occur. Instead, you should track route changes or component unmounts to capture relevant data during navigation.

As we can see in the challenges the tracking on clicks for navigation has it’s hurdles. To provide best data quality we implemented the sendBeacon method in all requests where possible. This API is different than regular XHRequest and has limitations, so not all data capturing can utilize it. And hence why not all JENTIS States and according events tracked are equal in terms of processing speed.

By design the following two States encorporate sendBeacon

  • JENTIS Data Layer (_jts.push({"track":"..."});) with the following track commands:

    • "event"

    • "addtocart"

    • "removefromcart"

    • "addtowishlist"

    • "removefromwishlist"

    • "productlistclick"

    • "promotionclick"

    • "promotionimpression"

  • SELECTORACTION State (any native click, form submit, etc. event with CSS selector in the JTM UI)

To make use of sendBeacon we recommend to use exactly this methods for fastest data submission. Specifically with events (ie. “click” listeners) that happen milliseconds before the page unload event we advise to make use of direct _jts.push() function calls to the mentioned events and submit the data.

Currently we do not provide support for custom solutions that can make use of sendBeacon with a custom JENTIS State.

Optimizing data tracking during page unload events is essential for collecting valuable insights into user behavior.

With the right calls to the JENTIS Data Layer you will be able to get the most out of your data. Utilizing asynchronous methods like navigator.sendBeacon, you can ensure that your tracking data is captured even as users navigate away from your site. While challenges such as timing issues and browser differences exist, careful implementation and testing can help overcome these obstacles, allowing for robust data tracking that enhances your understanding of user interactions. As you refine your tracking strategies, you’ll gain deeper insights that can drive improvements in user experience and engagement.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.