Title: Random Search Strings Being Generating
Last modified: October 8, 2023

---

# Random Search Strings Being Generating

 *  Resolved [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/)
 * Hi @[CornelRaiu](https://wordpress.org/support/users/cornelraiu-1/) I hope you’re
   well.
 * I’m using your plugin for more than full and a half year now and things were 
   working great until now. first my domain was valueautosdurango.com and now recently
   I changed my domain name from valueautosdurango.com to durangovalueautos.com 
   and migrated my website. and when I tested the website after domain change and
   migration I got this issue in plugin that whenever I search on the website the
   plugin automatically stores random search strings in the website. Here are some
   sample search strings plugin is storing in site automatically
 * [Toyota Rav 4/Page/3/About-Us/Blog/About-Us/About-Us/Reviews-Us-And-Testimonials/Inventory](https://durangovalueautos.com/?s=toyota+rav+4%2Fpage%2F3%2Fabout-us%2Fblog%2Fabout-us%2Fabout-us%2Freviews-us-and-testimonials%2Finventory)
 * [Toyota Rav 4/Page/3/Blog/Specials/Managers-Specials/About-Us/Reviews-Us-And-Testimonials/Service-And](https://durangovalueautos.com/?s=toyota+rav+4%2Fpage%2F3%2Fblog%2Fspecials%2Fmanagers-specials%2Fabout-us%2Freviews-us-and-testimonials%2Fservice-and)
 * [Toyota Rav 4/Page/3/Service-And-Parts/Careers/About-Us/Specials/Managers-Specials/Inventory](https://durangovalueautos.com/?s=toyota+rav+4%2Fpage%2F3%2Fservice-and-parts%2Fcareers%2Fabout-us%2Fspecials%2Fmanagers-specials%2Finventory)
 * see its somehow generating the string and including the pages in it dont know
   how and why?
 * I tried to delete the tables and also tried reinstalling the plugin but nothing
   worked. sometimes when i even browse the pages it stores these random strings
   in site.
 * What can be the thing causing the issue? Can you please check and resolve it.
 * Thanks for this great plugin
 * regards
 * Junaid
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Frandom-search-strings-being-generating%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/?output_format=md)

 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108360)
 * Hi [@jasghar](https://wordpress.org/support/users/jasghar/) ,
 * Thanks for reaching out.
 * It’s the first time I’ve seen something like this happening. There is a search
   that is being run with those strings, otherwise they wouldn’t be stored.
 * I’ve had a look at the website and it looks like everything works correctly on
   desktop. However, the mobile search in the header, redirects me to the /top-searches/
   page and it shows a list of searches and a weird “alert” showing “Ajax call sent”
   and it looks like it has some issues.
 * Since it worked well on the other setup, it’s most probably something around 
   the setup of the new instance, or some plugin interfering with the search results.
 * I can help you debug this, but I will need both admin access and code access.
   Is there a staging site where I can see this happening? 
   If you need me to help
   with this, please send me temporary access information to
 * Thank you,
   Cornel Raiu
    -  This reply was modified 2 years, 7 months ago by [James Huff](https://wordpress.org/support/users/macmanx/).
      Reason: email address for login offer removed
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108597)
 * Hi [@cornelraiu-1](https://wordpress.org/support/users/cornelraiu-1/) thanks 
   for your quick response. I tried and used HealthCheck and troubleshoot plugin
   and with troubleshoot mode active I deactivated all plugins and activated a default
   theme and deleted all search terms from db then tried to search on the website
   and after searching third time extra 3 auto generated strings were generated 
   and stored in db. search terms like this
 * [toyota rav 4/service-and-parts/accessories/service-and-parts/accessories/blog/inventory](https://durangovalueautos.com/wp-admin/index.php?page=search-analytics/admin/includes/class.stats.php&search-term=277)
 * you are right in mobile view the search bar is for a diffrent purpose its for
   filtering results in top-search results pages
 * actually the thing is the website is in production server and i am only getting
   this issue in production website and not getting in stage site. if you can check
   the issue and can fix by today then i can give you a temporary access cause site
   is in production and in use and getting traffic. please tell me what user role
   you want to check the issue.
 * Thanks for the support
 * Junaid
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108649)
 * Hi [@jasghar](https://wordpress.org/support/users/jasghar/) ,
 * I would need the highest role in order to also be able to look at the plugins
   and even code.
 * I will look at it but since it’s only reproducible in production, it’s most probably
   something with the website config. But I will look at it and try to see what’s
   wrong.
 * Thanks,
   Cornel Raiu
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108655)
 * [@jasghar](https://wordpress.org/support/users/jasghar/) it might have something
   to do with the other support tickets we solved a few months back:
 * [https://wordpress.org/support/topic/how-to-direct-users-on-the-specified-search-term/](https://wordpress.org/support/topic/how-to-direct-users-on-the-specified-search-term/)
 * [https://wordpress.org/support/topic/how-to-add-links-which-i-want/](https://wordpress.org/support/topic/how-to-add-links-which-i-want/)
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108665)
 * okay, making your credentials BTW if you like can you come in a google meet or
   something you’re comfortable with so I can also be with you during the debugging
   process.
 * Thanks
 * Junaid
    -  This reply was modified 2 years, 7 months ago by [jasghar](https://wordpress.org/support/users/jasghar/).
 *  Moderator [Support Moderator](https://wordpress.org/support/users/moderator/)
 * (@moderator)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17108857)
 * [@cornelraiu-1](https://wordpress.org/support/users/cornelraiu-1/) Regaridng “
   If you need me to help with this, please send me temporary access information”
   do not do that, it’s against both forum and plugin directory rules: [https://wordpress.org/support/guidelines/#the-bad-stuff](https://wordpress.org/support/guidelines/#the-bad-stuff)
 * Your account has been flagged so that all replies from you will need to be approved
   by a moderator before they are publicly visibile. Eventually, that flag will 
   be removed, but if you continue to ask for login credentials, you will be reported
   to the Plugins Team.
 * If you have any questions, you can reach the Moderators at forum-moderation (
   at) wordpress (dot) org
 * [@jasghar](https://wordpress.org/support/users/jasghar/) Similarly, do not probive
   them with login cedentials, as that is also against forum rules.
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17109505)
 * Hi [@jasghar](https://wordpress.org/support/users/jasghar/) ,
 * I will provide a few more things to check and try to come up with a solution 
   for this. It’s the safe way to do it.
 * Since you said you already tried disabling everything using the Health Check 
   plugin, I will not suggest that
    1. Can you try to comment out all the code we did for the other 2 support tickets
       you opened here and see if it still occurs? Not sure how it could affect this,
       but it’s worth giving it a try.
    2.  - [https://wordpress.org/support/topic/how-to-direct-users-on-the-specified-search-term/](https://wordpress.org/support/topic/how-to-direct-users-on-the-specified-search-term/)
        - [https://wordpress.org/support/topic/how-to-add-links-which-i-want/](https://wordpress.org/support/topic/how-to-add-links-which-i-want/)
    3. Try to delete all the search entries from the Wp Search Analytics tables – using
       the `"Erase All Data"` button in the plugin’s settings page – and check it after.
    4. Are you sure these are not bots doing these searches? Can you check Analytics(
       Google or whatever you are using ) and see if those searches were made by you/
       your users simply browsing the website or there are bots doing it.
    5. Do you have the `"Save Search Country"` option enabled in the settings? Is there
       any way for you to see if those were bot searches based on the country of origin?
       If not enabled, try to enable it and monitor the results
    6. Are there any “Custom Search Params” added in the plugin settings? Is there 
       a way that certain AJAX calls or REST API calls that might be running with the`
       s=` or any other custom search param you are using?
 * Regarding the bot search at point 3, I am working on a solution to enable and
   prevent bot search recording on the plugin. There’s no timeline for this yet.
 * One way to prevent these searches from being recorded is adding certain strings
   in the `Exclude search in case it contains certain substring` in the plugin settings.
   In this case, adding the `/` character should do it. However, this setting is
   being used for building a RegEx check so this character should be escaped, like
   this: `\/` . 
   Also, please make sure you don’t have a trailing comma in this 
   field because it might break the RegEx. If you still can’t get it to exclude 
   those searches, please post here the contents of the settings so I can assist
   you and make sure it has the correct format.
 * Looking forward to hearing from you.
 * Cornel Raiu
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17109761)
 * Hi [@cornelraiu-1](https://wordpress.org/support/users/cornelraiu-1/) ,
 * Thanks for a detailed comment
    - I already tried by removing that previous code from functions.php but issue
      still there
    - Already tried to remove all data using Erase all data option in settings also
      I tried to uninstall the plugin then deleted the plugins tables from db and
      then reinstalled but issue still there. also i tried to remove entries from
      db then switch to troubleshoot mode then tried and issue still there.
    - ummm not sure about this cause no user going to search for that string and
      if a user is new to website for sure he will not be aware of the pages of 
      website and theres no way he can search for that string with exact pages and
      vehicle names in it. if a user is already familiar with website why he would
      search for something like this with exact same pattern always.
    - I dont think the searches are made by the users cause when i removeed entries
      and tried to search then after maybe like third search 2 extra auto generated
      searches were added.
    - yes I do have country option enabled but the plugin is not showing country.
    - no ajax calls running with s=
    - I did added custom search params like this.
 * ![](https://tinyurl.com/ymkayqzq)
 * but as you mentioned that you are using regex and having trailing comma might
   break it then how should i place it in this field
 * BTW i do have a code which i am using to check for user search terms and redirect
   them to their exact searched page heres the code
 *     ```wp-block-code
       // check the searched term
       function search_listings_meta() {
           if (isset($_GET['s']) && !empty($_GET['s'])) {
               $term = sanitize_text_field($_GET['s']);
               $meta_query = array(
                   'relation' => 'OR',
                   array(
                       'key' => 'stock-number',
                       'value' => $term,
                       'compare' => '='
                   ),
                   array(
                       'key' => 'make',
                       'value' => $term,
                       'compare' => '='
                   ),
                   array(
                       'key' => 'model',
                       'value' => $term,
                       'compare' => '='
                   ),
                   array(
                       'key' => 'vin-number',
                       'value' => $term,
                       'compare' => '='
                   ),
                   array(
                       'key' => 'postName',
                       'value' => $term,
                       'compare' => 'LIKE'
                   ),
               );
               $args = array(
                   'post_type' => 'listings',
                   'meta_query' => $meta_query,
               );
               $query = new WP_Query($args);
               if ($query->have_posts()) {
                   $url = add_query_arg(array('search%5b%5d' => $term), home_url('/inventory'));
                   wp_redirect($url);
                   exit;
               }
   
               // compare search with pages
               $page = get_page_by_title($term);
               if ($page) {
                   wp_redirect(get_permalink($page->ID));
                   exit;
               }
           }
       }
       add_action('template_redirect', 'search_listings_meta');
       ```
   
 * maybe its possible that bots are performing these searches but why only on the
   production site not on the stage site. and why does only when I perform like 
   3 or 4 searches then it keeps add the auto-generated strings?
 * before the production site domain name was value******.com but now we changed
   it to durango**********.c* and we are facing this issue after changing the domain
   name before the plugin was working well even on the production site previous 
   domain name.
 * DK why this happening only on production site and only after changing the domain
   name.
 * regards
 * Junaid
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17110165)
 * Hi,
 * The country is only showing when viewing the not grouped results by clicking 
   the `No Group` filter on the results page.
 * Please send me the value of the `Exclude search in case it contains certain substring`
   setting so I can tell you if there is anything wrong with it.
 * I am not sure about why it’s happening only on the new domain. It doesn’t really
   make sense if the setup is identical to the previous domain.
 * My guess is still: bots, or some kind of links you are not aware of.
 * The code you posted in the previous comment seems to be fine, but I am not 100%
   certain about how the rest of the search works on your website.
 * Please send me the contents of that setting so I can, at least, instruct you 
   on how to exclude those entries from being saved.
 * Cornel Raiu
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/#post-17110392)
 * Hi, Here is the pattern i am using in exclude search string field
 *     ```wp-block-code
       /,_,{,},[,],.,|,\,.jp,
       ```
   
 * here are the content of settings i’ve set
 * ![](https://tinyurl.com/ykmr7753)
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/#post-17110757)
 * Hi,
 * Please try this one: `\/,_,\{,\},\[,\],\.,\|,\\,\.jp` . make sure you don’t have
   a trailing comma.
 * I know this is ugly, but this is how it works right now.
 * I am working on a solution to improve this.
 * Please let me know if this worked.
 * Thank you!
 * Cornel Raiu
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/#post-17111077)
 * Thanks for providing this.
 * Right now is day time and the website is functional I’ll try this after 6PM Mountain
   time. Like 12 PM romania time today.
 * Thanks. will try and update you.
 * Junaid
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/#post-17111315)
 * Hi, I somehow managed to update the live site and the provided code appeared 
   to be working fine. I made like 20 searches and it did add the searches in db
   but it excluded the searches containing the letters added in the ‘exclude’ field.
 * But I’ve a question
 * Is this the best of solution for the issue?
 * It’s recording multiple entries means if I search for ‘ford’ it will add ford
   in db. if i search for ‘ford’ again the second time it will still save it in 
   db. and will show duplicate entries. is it because I enabled the country option
   in the settings page?
 * what are these settings for?
 * exclude doubled search for same user if interval is lower than (minutes):
 * Add custom search parameters for recording the searches:
 * ///////////////////////////////////////////////
 * Just to ask if you could add a feature where we can exclude searches longer than
   some desired letters or work?
 * Thanks for all your support
 * Junaid
 *  Plugin Author [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * (@cornelraiu-1)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/#post-17111599)
 * Hi Junaid,
 * I am glad that the setting is now filtering out those searches correctly.
 * The solution would definitely be to see where those search links are being built
   and accessed and fix them. However I cannot assist you with that. So, in this
   case, simply excluding the results from being saved seems to be the best solution
   from my stand point.
 * The reason you are seeing multiple entries with the same search term is because
   you, most probably, clicked the `No Group` filter above the results. That way
   each individual search has its own entry in the results table. To revert to the
   aggregated results, simply click `Group By: Term`filter.
   The country setting 
   only affects the search results when viewing in the `No Group` mode.
 * The `exclude doubled search for same user if interval is lower than (minutes):`
   setting will prevent multiple identical searches from the same browsing session
   from happening. For example, if someone searches for “Ford” and then just refreshes
   the page 10 times within the number of minutes in the setting, it will only save
   the first search, because the others are duplicates.
 * The `Add custom search parameters for recording the searches:` allows you to 
   track other URL params for searches. The default one is `s` ( for searches like:
   domain.com/?s=ford ). And you might want to also save searches when the search
   parameter is `searchbar` or `search` or whatever other parameter makes sense 
   for your app.
 * Adding a feature to exclude searches longer than x characters in the plugin doesn’t
   really make sense. However, you may add a piece of code in your functions.php
   file that will do that:
 *     ```wp-block-code
       add_filter( 'mwtsa_exclude_term', function ( $excluded, $search_term ) {
           if ( $excluded ) {
               return $excluded;
           }
   
           // change 20 to the number of maximum characters you
           // want to allow.
           return strlen( $search_term ) > 20; 
       } );
       ```
   
 * I hope that helped.
 * Thank you,
   Cornel Raiu
 *  Thread Starter [jasghar](https://wordpress.org/support/users/jasghar/)
 * (@jasghar)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/#post-17111610)
 * Hi, Just want to know how can i add a plus sign in this pattern so the searches
   including plus sign also gets excluded
 *     ```wp-block-code
       \/,_,\{,\},\[,\],\.,\|,\\,\.jp
       ```
   
 * do i need to add like this \+
 * Thanks
 * Junaid

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/random-search-strings-being-generating/page/2/?output_format=md)

The topic ‘Random Search Strings Being Generating’ is closed to new replies.

 * ![](https://ps.w.org/search-analytics/assets/icon-256x256.jpg?rev=1832550)
 * [Search Analytics for WP](https://wordpress.org/plugins/search-analytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/search-analytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/search-analytics/)
 * [Active Topics](https://wordpress.org/support/plugin/search-analytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/search-analytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/search-analytics/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 32 replies
 * 3 participants
 * Last reply from: [Cornel Raiu](https://wordpress.org/support/users/cornelraiu-1/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/random-search-strings-being-generating/page/3/#post-17111747)
 * Status: resolved