This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

No result track

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #54885
    osmankocak212osmankocak212
    Participant

    Hello, Google Analytics connections have been made and I can see the search terms. What I want is to see only the search terms that didn’t find any results. What method can I use for this? The analytics part of the plugin is weak in this area, as far as I can see.

    #54888
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    For that there is indeed no setting as of yet – but it should be easily doable via a small custom code snippet via the javascript API.

    For that, I constructed this small snippet, which hooks into the container when the results are displayed and to sends a no_results event with the search phrase in the “phrase” property, when detects 0 results:

    add_action(
    	'wp_footer',
    	function () {
    		?>
    		<script>
    			document.querySelectorAll(".asp_main_container").forEach((el) => {
    				el.addEventListener("asp_results_show", (event) => {
    					// event.detail carries the arguments
    					const [id, instance, phrase] = event.detail;
    					const zeroResults = document.querySelectorAll('.asp_r_' + id + '_' + instance + ' .item').length === 0;
    					const noresContainerVisible = document.querySelectorAll('.asp_r_' + id + '_' + instance + ' .asp_nores').length > 0;
    					if ( zeroResults || noresContainerVisible ) {
    						// This is the GTAG event that is sent
    						gtag('event', 'no_results', {
    							'phrase': phrase,
    						});
    					}
    				});
    			});
    		</script>
    		<?php
    	}, 9999
    );

    Try adding this code via the Code Snippets plugin or 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.

    If you need any help with this, just le me know!

    #55063
    osmankocak212osmankocak212
    Participant

    Do you have any plans to improve this area in new versions? You can see more than the first 20 searches in the analysis section, and there’s a separate section with inconclusive search terms. Your plugin has many shortcomings in this area.

    #55068
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Yes, definitely. Statistics is one of the oldest features due to rework.

    If you have any specific suggestions you would like to see there in the future, let me know.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.