Skip to main content

Strategy and Transformation

Problem/Solution: Site search without a query string

Today’s problem/solution asks the question how do you use Google Analytics’ site search reports when there is now query string pattern in the url?
First off you need administrator level access for access to these settings. The complete path looks like this:

Admin > {select account} > {select profile} > {select property} > Profile Settings > Site Search Settings
Perficient: Digital Strategy Experts
The Future is Digital

Becoming digital is the surest way for you to understand your customers' needs and meet their expectations. Learn how Perficient can help anticipate what's ahead for you and your customer with a digital strategy centered around empathy, alignment, and agility.

Watch Now: Digital Strategy Experts

You’ll need to click on the Admin link on the top right of the orange bar and then select the account from the accounts list.  Once your account is selected choose the property and then the profile you want to apply this to.  Then you simply select Profile Settings and you’ll see the following under Site Search Settings.
site search
From here the basic settings are quite simple.  All you need to do is put in the query parameter that your website usually throws in the URL to designate the search term.  The above screenshot is from a WordPress blog so I used “s”.  Now Google Analytics will look in every url for “?s=search+terms” style strings and you will see “search terms” end up in the site search report.

How to use site search without a query string

Now that we know how it “should” work…how do we set things up when there is no search terms in the URL?  What if performing a search on your website doesn’t affect the URL at all?  This seems too simple to work when you think about it.  We simply create our own query string with Google Analtyics.  This is another solution we came up with for the client that had a complete POS system built with Ajax and never refreshes the URLs naturally.  We again use the ability to send virtual pages to Google analytics only this time we are appending a search query along with the search term to the url.  The code looks like this when you’re using analytics.js

ga('send', 'pageview', {
 page: '/searchresults?query=shoes'
});

All you have to do is fire that off with the appropriate search term whenever your customer uses site search and you’ve formatted your URL to something Google Analytics will process within the site search settings.  Google Analytics will receive the full URL including the parameter and its value. We then would go back into site search settings and simply add in “query” for the query parameter so that Google knows to strip out the following search term and place that data into the site search reporting.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Andy Scott

Follow me onGoogle+.

More from this Author

Follow Us