Hey there!
I'm Benjamin from Loves Data.
In this video you will learn how to configure the Site Search reports in Google Analytics
even if you don't have a query parameter.
If you're not familiar with the site search reports - they allow you to track what people
are searching for within your own website.
They give you insights into how people are using your website's search function.
If you're just getting started with Site Search, then check out my blog post which covers all
the details you'll need to get started.
You'll find a link in the description below.
Okay, so if you're still watching, that means you're in the right place!
We're going to use Google Tag Manager to grab the search query from our search results page
and then send a pageview to Google Analytics that includes that search query as a query
parameter.
We'll basically be sending a virtual pageview to Google Analytics.
Let's get started!
The first thing you will want to do is head to your website and perform a search.
If you can see the keyword you searched for in your browser's URL bar, then it's likely
that you can configure the Site Search reports without needing to change anything in Google
Tag Manager.
For example, if you see the search query, but it doesn't use a query parameter, then
you can use a filter inside Google Analytics to modify the URL and configure the reports.
Let's look at an example I've created that doesn't use a query parameter...
Here we can see a simple search function.
I can enter a term and perform a search...
Now we can see we have the search results page, but importantly, if we look at the URL
bar we can't see my search query.
I can't see 'contact'.
However we can see 'contact' is on the search results page.
Let's take a look at the source code...
We can see that contact is contained in a heading tag with the ID of 'search-term'.
So we can use this inside Google Tag Manager to grab the content of this tag.
Let's head to Google Tag Manager...
Let's start by creating a new tag...
We select 'Universal Analytics' and name the tag 'Google Analytics Search Results'...
Select 'Enable Overriding Settings'...
And then select 'Fields to Set' and 'Add Field'.
Now we need to enter 'page' as the 'Field Name' and we're going to enter / search ? q
= and now we're going to click on the add variable icon.
Let's create a new variable...
We're going to select 'DOM element' as our 'Variable Type'...
And name the variable 'Search Query'...
Then we select 'ID' and enter the ID from the heading tag we found on our website.
For my example this is 'search-term'.
Now we can save the variable.
Next we need to choose a trigger for our tag...
Let's create a new trigger...
And name it 'Search Results Page'...
Now we select 'Page View' as the 'Trigger Type'...
And select 'Some Page Views'...
We choose 'Page Path', 'Contains' and enter the path for our search results page.
For our example, this is '/ search results /'. Now we save our trigger...
This will mean that our tag that send the virtual pageview with the query parameter
included will only fire on our search results page.
We can save our tag.
Finally we should add an exception trigger to our existing Google Analytics tag.
If we don't do this then we will have two pageviews fired on our search results page.
So let's select the tag...
And add an exception...
Let's select the 'Search Results Page' trigger...
And save the tag.
Let's head back to our search page...
And perform the search again...
Now let's head to Google Analytics...
We can see that the page is now reported in the Real Time reports along with the search
query.
So now we can head to the 'Admin' section and configure the Site Search reports.
We just need to select 'View Settings' and enter 'q' as the query parameter for the site
search settings.
Now you'll begin to see information collected into the Site Search reports.
That's it!
So that's how you can setup the Site Search reports in Google Analytics even if you don't
have a query parameter.
Now that you're tracking what people are searching for on your website it's time to begin using
the reports.
You'll find valuable insights in the reports that allow you to identify things like gaps
in content, navigation issues and even keyword ideas for your search campaigns.
For tips on how to use the reports read my post on using the Site Search reports.
You'll find a link in the description below.
Have you configured the Site Search reports?
I'd love to know!
Let me know and leave your tips in the comments below!
See you next time!