I have a Joomla 3 Website with (paid) Google Site Search on it. A search shows the results on the same page in a module without changing the url (no q=keyword or so). That works perfectly. But I want to track the search results in Google Analytics. To do that it seems the keyword has to be shown in the url, how can I do that? I tried to add this code to the analytics code, but still it didn't work: analytics.js: ga('send', 'pageview', '/search_results.php?q=keyword');
Here's the website i'm talking about: Kostümverleih Kaiser
Help is very appreciated!
This is my searchbox so far:
<div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="//www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript">// <![CDATA[
google.load('search', '1', {language: 'de', style: google.loader.themes.V2_DEFAULT});
google.setOnLoadCallback(function() {
var customSearchOptions = {};
var orderByOptions = {};
orderByOptions['keys'] = [{label: 'Relevance', key: ''} , {label: 'Date', key: 'date'}];
customSearchOptions['enableOrderBy'] = true;
customSearchOptions['orderByOptions'] = orderByOptions;
var imageSearchOptions = {};
imageSearchOptions['layout'] = 'google.search.ImageSearch.LAYOUT_POPUP';
customSearchOptions['enableImageSearch'] = true;
var customSearchControl = new google.search.CustomSearchControl('016730512287540754301:jb0a5lrvf3y', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setSearchFormRoot('cse-search-form');
options.setAutoComplete(true);
customSearchControl.setAutoCompletionId('016730512287540754301:jb0a5lrvf3y+qtype:1');
customSearchControl.draw('cse', options);
}, true);
// ]]>
// ]]></script>
Maybe there is a way to send the search to Google Analytics as an Event with the Keyword as proposed in the first answer?