Hello,
Thank you for contacting me. Using the custom parameters works on regular search but it doesn’t always work depending on the setup.
If you have control over your code you can some code after your WP_Query call to insert the search term in the Search Analytics tables:
$custom_wp_query = new WP_Query( array( ... ) );
(new MWTSA_Process_Query())->process_search_term($search_term, $custom_wp_query->found_posts);
This will do all the extra things that Search Analytics for WP does before inserting the term: IP Checks, Exclude for roles, blacklist words, country identification, etc.
Please let me know if you need any more help with this.
Have a great day,
Cornel Raiu @ Master WebTools
Hello! Thank you for the reply, I have added the snippet after my WP_Query call and now it’s working. But it seems that it wrongly counts number of searches in “No. of searches” column: It always increments by 2. Could you please advise if that can be fixed?
-
This reply was modified 10 months, 2 weeks ago by
alexpalshin.
-
This reply was modified 10 months, 2 weeks ago by
alexpalshin.
Hello,
I am glad what we did works. The reason why it records 2 entries is because the regular code of the plugin also understands that a search is happening and it records it, but as far as you said, it didn’t work correctly.
To understand it better, I need answers to the following questions:
- If you take off the code we added, does it still record on search entry?
- If “yes” on point 1, does it also count the results correctly?
- Did you add anything to the custom search parameters in the plugin settings?
- If “yes” on point 3, does it still record twice if you remove it and leave it empty?
Just a note: everything can be fixed with enough patience!
Thank you,
Cornel Raiu @ Master WebTools
Hello!
- No it doesn’t add any records without the code added.
- –
- No, the field for custom search parameters is empty.
Also I found the option “Exclude doubled search for same user if interval is lower than ( minutes )” and set it to 1. It fixed the issue. Is this the correct solution?
Hi,
I am glad you fixed it.
Are you using the same search parameter: s= just like default WordPress search does? if yes, then it makes sense to record it twice.
I would say it is a fix. Not a perfect one because it’s clear the search runs twice. But this outside of this plugin’s scope.
If I were you, I would add a debug log right before the WP_Query call and see if it runs twice. You might have the AJAX call triggering twice when launching the search.
Please let me know if I can be of further assistance.
Also, if you like my plugin, I’d appreciate you leaving a review saying what you think about it. It’s a 100% free plugin, so this is my only incentive to keep going with it.
Thank you and wish you a great day,
Cornel Raiu @ Master WebTools
Thank you very much for your hard work and your assistance! For sure I’ll leave a review!
-
This reply was modified 10 months, 2 weeks ago by
alexpalshin.