夏期劇場
夏期劇場

Reputation: 18325

Google CSE "Search Term(s)" to be saved in own way?

Since i'm using Google CSE, the main idea is to show the "Top Search Terms" under the CSE Search box. But in the CSE panel, Google is saying:

No queries were sufficiently popular to be listed

So anyway (i don't want to wait it to be sufficient enough and) .. i want to implement it on my own.

Or

.

As a reference, this is all i've done so far:

<!-- Goolge CSE -->
<script language="JavaScript">
  (function() {
    var cx = 'xxxx3941849086xxxxx:xxxxmtk5xxxxxx';
    var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
  })();
</script>
<body>
    <!-- GCSE Search Box -->
    <div class="global-search">
        <gcse:searchbox-only  linktarget="http://www.example.com/search" queryParameterName="query"></gcse:searchbox-only>
    </div>
    <!-- GCSE Result Div -->
    <div id="googlecse-result">
        <gcse:search linktarget="_parent" queryParameterName="query"></gcse:search>
    </div>
</body>

Upvotes: 0

Views: 499

Answers (1)

Dave Hogan
Dave Hogan

Reputation: 3221

I find the value of the search term here and save in my own db:

google.search.cse.element.getElement('standard0').getInputQuery()

I wouldn't advise you hardcoding 'standard0'.

If you give your gcse elements a name using gname="SomeName" then you can use this as a reference.

google.search.cse.element.getElement('SomeName').getInputQuery()

Upvotes: 1

Related Questions