June 09, 2023

Kevin Montgomery

|

6 min. read

SearchStax Site Search is a highly scalable site search solution that offers a host of enterprise-class features in an easy-to-deploy package. 

In particular, SearchStax Site Search’s rich analytics provide visibility into user behavior, helping web and content teams to make better-informed decisions about how to improve the search experience. If you’re not currently a Site Search customer, this article will provide value, and we also recommend learning more about Site Search or scheduling a demo.

For Site Search customers, leveraging site usage data can help marketers, developers, and team managers with improved ability to build optimal user journeys through your site, gain key content insights and optimization recommendations, generally improve the site search experience, and get better value out of the site search analytics within SearchStax Site Search.

Many brands are already tracking basic site analytics data with Google Analytics. Google Analytics 4 offers the flexibility to customize what data and events are tracked and captured from your site. Adding customized dimensions, metrics, and events for your site can help capture more -granular visitor data and provide more visibility about what your site visitors are doing and looking for on your site.

This guide shows how you can capture search and click through events from the SearchStax Site Search Hosted App using Google Analytics 4. Tracking will use Google Analytics 4 to record search and click through events as well as Google Tag Manager to add the appropriate tags, triggers, and variables to capture those events. Combining site-wide analytics data from Google Analytics with SearchStax Site Search can help improve keyword and topic targeting, identify content gaps and opportunities, as well as inform user experience improvements to site navigation, on-page features, and promotional messaging.

Getting Started

You’ll need a Google Analytics 4 account, Google Tag Manager account, and SearchStax Site Search account to get started. Once these accounts and properties are set up and implemented on your site, you can start customizing and tracking more user interactions.

We’ll be using Google Tag Manager to handle the additional tracking tags and configuration so make sure that your GA4 tags are deployed and available in Google Tag Manager before continuing.

Configuring GA4 Custom Dimensions and Events

In order to accurately capture and report on internal site search events we’ll need to configure some additional custom events and dimensions in your Google Analytics 4 property. These custom events and dimensions will be available in the Report Explorer and can also be accessed via the Google Analytics 4 Data Reporting API.

Events

We can add additional dimensions to the `view_search_results` event that is already included in Google Analytics 4. By default Google Analytics 4 will attempt to capture internal site search events and queries when ‘Enhanced Measurement’ is enabled (GA4 > Admin > Property > Data streams) with URL parameters.

We’ll be sending a new `view_search_results` event for each new SearchStax Site Search using Google Tag Manager to watch for URL changes and extract the appropriate data from the search URL parameters.

We’ll also need to create a new event called `searchstax_click`. The event_name parameter for this event should be equal to `searchstax_click`.

Dimensions

We’ll also need to configure some additional dimensions to capture the search queries and faceting/sorting preferences from the SearchStax Site Search results page.

  • Add `searchstax_query` dimension for SearchStax site queries
  • Add `searchstax_facets` dimension to capture facet selections
  • Add `searchstax_order` dimension to capture search result sorting
  • Add `searchstax_destination_page` dimension to capture click through data

     

Once these events and dimensions have been added in GA4, you can start configuring Google Tag Manager to watch for the user actions on the SearchStax search result page and send the appropriate events and data to GA4.

Configuring Google Tag Manager

Google Tag Manager will be used to watch for changes to the SearchStax Site Search result page and send tracking events to Google Analytics 4. The SearchStax Site Search hosted app updates the page URL with every search and will set the appropriate parameters for the search query, facets, and sorting options.

Variables

First we’ll add the appropriate variables to Google Tag Manager for the search dimensions. We’ll use the built-in `Click URL` and `Click Class` variables as well as custom variables for SearchStax Sie Search dimensions.

Next we’ll create the User-Defined Variables for search queries, pagination, facets, and sorting.

GTM Variable Name

Query Key (URL Parameter)

SearchStax Query

searchStudioQuery

SearchStax Page

start

SearchStax Sort Order

orderBy

SearchStax Site Search includes some default facets such as ‘content_type’ and ‘author’, but you can add additional facets based on your content, categorization, and taxonomy. We’ll use some custom JavaScript to parse the selected facets and set them as a dimension instead of trying to hard-core those values in GTM.

function () {

  var params = new URLSearchParams(window.location.search);

  var facets = params.get(‘facets’).split(“&”);

  var selectedFacets = [];

  for(var i = 0; i < facets.length; i++) {

selectedFacets.push(facets[i].split(“:”)[0].replace(“fq=”,””) + “=” + facets[i].split(“:”)[1]);

  }

  return selectedFacets.join(“, “);

}

Triggers

We’ll create two triggers to send search data. The first trigger will watch for history changes as a user searches, sorts, or selects a facet. The second trigger will capture clicks on the actual search results.

This trigger will fire anytime the URL changes and it contains the `searchStudioQuery` parameter. This parameter is included for every search action.

The `Search Result Click` trigger will fire when a user clicks on a search result. This trigger looks for any clicks that come from a link with the class `stretched-link` – this is the class that’s applied to every search result in SearchStax Site Search.

Tags

Lastly we’ll create two tags that will send the `view_search_results` event as well as the custom `searchstax_click` event.

The `SearchStax Search Update` event will send a `view_search_results` event to GA4 with the additional searchstax_query, searchstax_facets, searchstax_start, searchstax_order, and the page_location of the search itself. This tag will get triggered by the `Search URL Change` trigger that was set up earlier.

The next tag will handle search result click throughs using the custom `searchstax_click` event. This tag will include `searchstax_query` and `searchstax_destination_page` as dimensions. This tag gets fired from the `Search Result Click` trigger.

Deploy and Test

Once the default and custom variables, triggers, and tags have been configured, you can deploy your updated Google Tag Manager container to your site for testing.

Load the search page, perform a search, and click on a result. If Google Analytics and Tag Manager have been configured correctly you should see these events in the Realtime Events view.

Reporting

You’ll be able to start building reports with these new events and dimensions 24 hours after they’ve been set up and begin streaming data into Google Analytics 4.

Basic Keyword Trends

Capturing search keywords can help establish what terms and topics your site visitors are looking for but weren’t able to find with fixed navigation.

Page Click Through Data

Combining search keywords and destination pages will show what search results resonated most with users. You can also identify ‘no click’ search keywords [no click searches have a destination page set to ‘(not set’)] and patterns where users searched but didn’t actually click through to a destination page.

Page and Keyword Heatmaps

You can also visualize keyword and destination pages with a heatmap to identify keywords with multiple destination pages or pages that attract searches from multiple keywords. This data can help inform content improvements and segmentation to ensure that keywords and topics are correctly aligned with page content.

Additional Analysis

Click through trends and keyword data can be compared with other dimensions and metrics from your site to learn more about how users found your search page and where they went after. You can also segment site search data by location, device type, demographic data and more to uncover deeper insights about who is searching on your site and why.

Hopefully you’ve gained some valuable insights into how to best leverage GA4 and Site Search to optimize your site experience and improve engagement. If you’re not currently a Site Search customer, feel free to schedule a demo. If you’re already a Site Search customer, learn more about SearchStax Site Search Analytics APIs.

SearchStax Site Search FAQs

What is SearchStax Site Search?

SearchStax Site Search is a powerful site search tool that delivers actionable insights for marketers to understand user behavior and uncover improvement opportunities.

How much does SearchStax Site Search cost?

SearchStax Site Search is available at professional, business, and enterprise level pricing. Visit our pricing page for a deeper dive.

By Kevin Montgomery

Product Marketing Engineer

"...For Site search customers, leveraging site usage data can help marketers, developers, & team managers with improved ability to build optimal user journeys through your site, gain key content insights and optimization recommendations, and generally improve the site search experience..."

You might also like: