Site Search for Post-based search result
I've search option in my website which shows result in POST based query. So, there is no url string generating in search result. ie. mywebsite.com/search_result.php
Now, I want to set Site Search in my Google Analytics. The solution from Analytics help in https://support.google.com/analytics/answer/1012264 suggests:
Setting Up Site Search for POST-Based Search Engines
If you're using a POST-based search engine, the your-search-results URL would look something like:
You have two options to use Site Search for POST-based search engines:
Option 1: Configure your web application to append the query keywords to the end of the URL (e.g., http://www.yoursite.com/search_results.php?q=keyword) and then set up Site Search as described in the previous section.
Option 2: Customize the tracking code on your results page to dynamically specify a virtual page path that includes the query keywords. The tracking code on the results page would look something like:
analytics.js: ga('send', 'pageview', '/search_results.php?q=keyword');
I can not use option 1 and I'm not getting what option 2 exactly means. If someone can explain it to me, it'd be great. I understood that q is the query string name passed in POST but what is keyword?
Thanks in advance
Re: Site Search for Post-based search result
q is the query string and keyword is what someone search on the site for.
So presume I come to your site and search for "cat videos"
In this case you need to configure your code to output the following code:
analytics.js: ga('send', 'pageview', '/search_results.php?q=cat videos');
So the keyword is the actual query someone typed in your site search.