How to track irregular site search in Google Analytics | BCS

How to track irregular site search in Google Analytics

Google Analytics BCS 8 months ago (12-12) 155 Views 0 Comments

We know that the  search console report in Google Analytics is very useful, not only to know what the user has searched, but also to know some behavior after the search.

This report needs to be set before data is available. If the URL after your search meets the specifications, then the setup is simple. If your search URL does not meet the specifications, then you need to make some adjustments in Google Tag Manager, and you can track it.

If your site’s search URL looks like this: http://www.bbccss.com/?q=keyword, then that’s normal; if your site’s search URL looks like this: https://www.bbccss.com/search / keyword, that is the unconventional case. Unfortunately, my website is unconventional.

Let’s take a look at how to set up these two situations:

Normal situation

Our search URL is http://www.bbccss.com/?q=keyword, this setup is very simple,In the View column, click View Settings. Under Site Search Settings, set Site Search Tracking to ON:

How to track irregular site search in Google Analytics

 

  • Query parameter: enter the word or words that designate internal query parameters, such as term, search, query, keywords. Sometimes query parameters are designated by just a letter, such as s or q. Enter up to five parameters, separated by commas. Do not enter any additional characters, The search URL here is: http://www.bbccss.com/?q=keyword, because enter q.
  • Strip query parameters out of URL: Select whether or not you want Analytics to strip the query parameter from your URL. This strips only the parameters you provided,Generally not set.
  • Site search categories: If there is a search position on the website, then it needs to be turned on, and an additional parameter needs to be set to distinguish different search positions.

Here, our search URL is http://www.bbccss.com/?q=keyword, so we need to set q in Query parameter, the complete setting is as follows:

How to track irregular site search in Google Analytics

Here, our search URL is http://www.bbccss.com/?term=keyword, then the Query parameter needs to be set to term.

That’s it, Search Console will have data.

 

 

Unconventional situation

Special cases, such as my blog search:

How to track irregular site search in Google Analytics

We can’t set it directly through Site Search Settings, but we can rewrite the URL through Google Tag Manager so that the URL meets the structural requirements of Site Search Settings, which is the structure of q = keyword.

1、Create a Custom JavaScript

Create a Custom JavaScript in Google Tag Manager and name it Search,Then copy the following code into it:

<span style="font-size: 12pt;">function(){
  var url= document.URL
  if (url.indexOf('/search/')>-1){
    return url.slice(30)
  }
}
</span>

The function of this code is to intercept the characters after / search /, that is, the search word, as a variable.

Effect after configuration:

How to track irregular site search in Google Analytics

2、Create a trigger

Create a trigger named Search Pages and configure it as follows:

How to track irregular site search in Google Analytics

 

3、Create a Tags

Create a Tag named: Rewrite Search URL,Then do the following settings:

How to track irregular site search in Google Analytics

The important point is to set the page to {{Search}} variable in the Field to Set, and the trigger selects Search Pages.

4、Adjust the default Google Analytics Tags

Adjust the default Google Analytics Tags to exclude Search Pages, otherwise it will trigger twice. Google Analytics Tags are the tags that send data to Google Analytics:

 

How to track irregular site search in Google Analytics

5、Set Site Search Settings

Set Site Search Settings after URL adjustment specifications:

How to track irregular site search in Google Analytics

6、Preview and Test

How to track irregular site search in Google Analytics

 

Back to Google Analytics real-time reporting:

How to track irregular site search in Google Analytics

 

The URL in Google Analytics has changed.

 


If you don't understand, You can leave a comment below or email me (haran.huang@ichdata.com).
Like (0)
Post my comment
Cancel comment
Expression Texture Bold Strikethrough Center Italic Sign in

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website