Filipe Lourenco : How to enable Site search via Google Tag Manager

The 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 that should be taken in consider: The user should make sure that the deployment of our script is already made on the Tag Manager os that the statistics are ready to collect data.https://help.monsido.com/en/articles/5556032-google-tag-manager-monsido-deployment
The 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.

The user should be able to add a script to your search results page.

This functionality is set with Javascript so the next step it will be the creation of a new tag, and the type should be Custom Tag.

selection of the tag

Custom tag (HTML)

The tag configuration will popup on a side window and the user should make sure to configure it properly.

First, rename the tag. That option is on the left top corner of the window
Second, that is the most important field because you will to add the site search script.

 <script>
  window.addEventListener('mon-script-loaded', function() {
    //console.log("Script loaded successfully!");
    if ( window.monsido_functions ) {
      var urlSearchParams = new URLSearchParams(window.location.search);
      var params = Object.fromEntries(urlSearchParams.entries());
      if (params.searchString) {
        window.monsido_functions.trackSearch(params.searchString);
      }
      //console.log("Script loaded!");
    } else {
      var urlSearchParams = new URLSearchParams(window.location.search);
      var params = Object.fromEntries(urlSearchParams.entries());
      if (params.searchString) {
        window.monsido_functions.trackSearch(params.searchString);
      }
    }
  });
</script>

Note: Make sure to adjust the script and replace searchString for the correct parameter - (i.e - search or q based on the previous example).
Third, you can select the tag to be trigger on one or several pages and for that the user might need to adjust the trigger configuration - https://support.google.com/tagmanager/answer/7679316?hl=en

After all steps completed, the user just need to save and publish the changes.

For CHR Hansen:

https://tagassistant.google.com/#/?id=GTM-54WHHL&url=https:%2F%2Fwww.chr-hansen.com%2Fen%2Fsearch%3Fterm%3Dprobiotics%26gtm_debug%3D1676279359635&source=TAG_MANAGER&gtm_auth=UgRxSfY83f_8WHRQ7gWwCA&gtm_preview=env-38