All Collections
Archive
How to set up Site Search
How to set up Site Search

Track what visitors are searching for on your website with Monsido Site Search

Updated over a week ago

The contents of this article have been updated and moved to:


Monsido Site Search is a search tracking feature in the Statistics module that allows you to track which words and phrases your visitors have searched for when using your website's search option.

Requirements

In order to track searches on your website, the following requirements must be fulfilled:

  1. The Monsido script must be present on your website and the Statistics feature enabled. Read more about adding the Monsido script to a website.

  2. Your website must have a search option and when a search is executed, the search results must display on a dedicated search results page that uses a URL parameter with the search query. For example, if a visitor searches for the word "holiday", the search results page URL must contain "holiday". It could be like domain.com/search?search=holiday or domain.com/s?q=holiday, etc.

  3. You must be able to add a script to your search results page.

Video Guide: How to set up Site Search

Duration: 4 minutes

Written Guide: How to set up Site Search

  1. Make sure your website and Monsido configuration meet the basic requirements for using search tracking.

  2. In your CMS (website builder software), locate your search results page.

  3. Add the following script to your search results page in the <body> tag:

    <script>
    window.addEventListener('mon-script-loaded', () => {
    const urlSearchParams = new URLSearchParams(window.location.search); const params = Object.fromEntries(urlSearchParams.entries());
    if (params.searchString) { window.monsido_functions.trackSearch(params.searchString);
    }
    });
    </script>

  4. To make the script track site searches properly, you'll need to modify it slightly. Replace searchString with the search query parameter used on your website. To find this, perform a search on your website and look at the URL of your search results page. The search query parameter name typically appears in between the characters ? and = in the URL. Here are two examples:

    Example 1
    On this search results page, the query parameter name is keys.


    Example 2
    On this search results page, the query parameter name is cludoquery.


    Please note that searchString appears two places in the script and will need to be replaced in both places.

    If we assume that our query parameter name is keys, the script should be modified so that it looks like this:

    <script>
    window.addEventListener('mon-script-loaded', () => {
    const urlSearchParams = new URLSearchParams(window.location.search); const params = Object.fromEntries(urlSearchParams.entries());
    if (params.keys) { window.monsido_functions.trackSearch(params.keys);
    }
    });
    </script>
  5. Publish your website. Monsido is now tracking site searches.

  6. In Monsido > Statistics > Content > Site Search you can view a list of the terms and phrases your visitors have searched for. The table contains the following information:

    Search term: The word or phrase visitors searched for.
    Searches: The number of times the particular term has been searched for.
    Average no. of results pages viewed: When a visitors perform a search, they sometimes get several pages of search results. This indicates, on average, how many search results pages visitors viewed for the search term. Tracking this data requires an advanced script setup. Please see our Developer docs for more information.
    % of search exits: The percentage of visitors who left the website (bounced) immediately after executing the search.

It may take up to 24 hours for search data to appear in the Monsido interface after a visitor has performed the search.

Did this answer your question?