Statistics issue when user presses 'return'

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Statistics issue when user presses 'return'

This topic contains 12 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 10 months, 2 weeks ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #35186
    itsjonesyy70
    itsjonesyy70
    Participant

    Hi there,

    I have enabled statistics on the plugin so I can use the ‘popular searches’ widget. It is working fine but I have noticed that when the user enters their query and presses the return key on the keyboard, the search is not logged and is not seen in the statistics. They are only logged if the user clicks the search icon or clicks a result in the preview.

    Is there a fix for this?

    Thanks

    #35198
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    You are right, those queries should be recorded too. I think there is a bypass solution to it though.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_action('asp_results', 'asp_add_stat_noajax', 10, 4);
    function asp_add_stat_noajax($results, $id, $is_ajax, $args) {
    	if ( !$is_ajax ) {
    		asp_statistics::addKeyword($id, $args['s']);
    	}
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35222
    itsjonesyy70
    itsjonesyy70
    Participant

    Hi,

    The code doesn’t seem to fix it. I have tested searches with a return key press and they still do not appear in statistics. The code also breaks the plugin preview results.
    The access link is still usable, please let me know if you need any more information

    #35227
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Can you please try this variation instead:

    add_filter('asp_results', 'asp_add_stat_noajax', 10, 4);
    function asp_add_stat_noajax($results, $id, $is_ajax, $args) {
    	if ( !$is_ajax ) {
    		asp_statistics::addKeyword($id, $args['s']);
    	}
            return $results;
    }

    Also, make sure the search override feature is enabled, otherwise the plugin may not trigger.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35228
    itsjonesyy70
    itsjonesyy70
    Participant

    Hi ernest,

    Thanks for the update.

    Maybe this helps – I’ve noticed that the issue of searches not being logged only occurs when the return key is pressed very fast (so before the preview results have even appeared). If the user types their query, waits a second for preview to load and appear, then presses return, it will be logged in statistics as normal. This is without any custom code applied.

    So currently the custom code (old and new variation) does not have any impact on the fast return key presses.

    Thanks again.

    #35236
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35243
    itsjonesyy70
    itsjonesyy70
    Participant

    OK, that would be great 🙂

    Thanks

    #35526
    itsjonesyy70
    itsjonesyy70
    Participant

    Hi Ernest, is there an ETA for when this will be fixed?

    Thanks

    #35543
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    It had been fixed within release 4.21.4 about two weeks ago, if you update to the latest release (4.21.5), it should be okay now.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35568
    itsjonesyy70
    itsjonesyy70
    Participant

    Am currently on 4.21.5 and it doesn’t look like anything has changed. A fast search query before results are previewed does not appear in statistics.

    #35575
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Do you have the search override feature enabled?
    Make sure to turn it on, otherwise the plugin search override may not trigger when redirecting to the results page.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35594
    itsjonesyy70
    itsjonesyy70
    Participant

    Ah, sorry I missed this. Not able to use the override otherwise my results filtering breaks. So to confirm, search override has to be enabled in order to catch the fast search queries in statistics?

    #35609
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I’m afraid yes, but maybe with a custom code there is a way to trigger it whenever the search results page is displayed.

    add_action('posts_results', 'asp_trigger_search_stat');
    function asp_trigger_search_stat() {
    	if ( is_search() && isset($_GET['s']) && $_GET['s'] != '' ) {
    		asp_statistics::addKeyword(-1, $_GET['s']);
    	}
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.