• Resolved palekgram

    (@palekgram)


    Hi

    I have an issue where the counter does not update when posts are accessed through AJAX using FancyBox. It supposed to track views for posts opened via FancyBox modals, and while the AJAX request seems to be successful (indicating no errors in the console), the view counter for the posts does not reflect the new views.

    Here are the details of my implementation and debugging efforts:

    1. AJAX Request Setup: I’ve set up an AJAX call that triggers when a post link is clicked. The request is sent to wp_ajax_nopriv_tptn_tracker and wp_ajax_tptn_tracker actions with the post ID and activate_counter set to 11, mirroring the behavior observed when accessing posts directly.
    2. Debugging Logs: Adding debug logging to the update_count function within the plugin’s class-tracker.php file shows that the function is called with the correct post ID and activate_counter. However, the view counter still does not update.
    3. Response Handling: The AJAX response handling in JavaScript uses response.text() and logs a success message, but it does not display any response data, suggesting that the server-side handler might not be sending back data as expected.
    4. Direct Page Access: When accessing a post directly (not through AJAX/FancyBox), the counter updates as expected, with activate_counter received as 11 in the debug log, indicating that direct access correctly triggers the counter update.

    I think there is an issue with how AJAX requests are handled or how view counts are updated and cached. How do I ensure that views from AJAX-loaded content are correctly tracked and reflected by the plugin?

Viewing 1 replies (of 1 total)
  • Plugin Author Ajay

    (@ajay)

    @palekgram, sorry for the delay. Are you able to provide me with the code you’re using – and your site URL to check. Do you have debug mode turned on in the Tracker tab? When this is on, it throws out some response tt and ttd which means it is working fine.

    Assume you have the cache disabled? One thing I am thinking that might be the issue with fancy box is if it is not pulling the correct post ID and so you’re seeing an update but it isn’t of the post. But, I believe you’re checking the ajax request also being sent?

Viewing 1 replies (of 1 total)
  • The topic ‘Issue with View Counter not updating for AJAX Content’ is closed to new replies.