我有一个Joomla 3网站上有(付费)Google Site Search。搜索在模块中的同一页面上显示结果而不更改URL(无q =关键字左右)。这非常有效。 但我想在Google Analytics中跟踪搜索结果。要做到这一点,似乎关键字必须显示在网址中,我该怎么做? 我尝试将此代码添加到分析代码中,但仍然无效: analytics.js:ga('send','pageview','/ search_results.php?q = keyword');
以下是我正在谈论的网站:Kostümverleih Kaiser
非常感谢帮助!
到目前为止,这是我的搜索框:
<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>
也许有办法将搜索结果作为第一个回答中提出的关键字的事件发送到Google Analytics?