CustomSearchControl - ads never shows at first time page loads

14 views
Skip to first unread message

Tarry

unread,
Oct 15, 2009, 6:06:13 AM10/15/09
to Google AJAX APIs
Hi!
I noticed this problem. Here is a piece of code that loads the page
with search results.

customSearchControl.execute('Google history');

And this code will never show Adsense. This can be seen even on many
pages with examples of code in Google.

However, if you click on search button on a customSearchControl,
advertising is beginning to appear. How do I fix this? Thank you!

Tarry

unread,
Oct 28, 2009, 5:12:41 AM10/28/09
to Google AJAX APIs
So, any ideas?

Olaf Lederer

unread,
Oct 29, 2009, 3:42:37 PM10/29/09
to Google AJAX APIs
I use the same function, and I see at least one ad

maybe google doesn't server so much ads in your country?

try popular search queries

Dusty

unread,
Nov 21, 2009, 5:04:50 AM11/21/09
to Google AJAX APIs
I am the the USA. I am having the same problem. The search works fine
with manual input, but when using the .execute function it will not
display AdSense on the first execution.

Any solutions found yet? I have exhaustively searched the web and read
over the documentation.

Thanks,
D.


Sebastiaan Deckers

unread,
Nov 25, 2009, 4:49:03 PM11/25/09
to Google AJAX APIs
Adding a delay to execute("...") appears to work around this problem.
Though obviously this trick makes the query slower and it's not
reliable as it depends on how quickly the user can load the page.

Example:

google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function () {
/* Typical code sample for a CSE */
var customSearchControl = new google.search.CustomSearchControl
('partner-pub-***************************************');
customSearchControl.setResultSetSize
(google.search.Search.LARGE_RESULTSET);
var options = new google.search.DrawOptions();
options.setSearchFormRoot('cse-search-form');
customSearchControl.draw('cse', options);
/* The following is the workaround */
setTimeout(function () {
customSearchControl.execute("test");
}, 1000);
}, true);


Can someone from Google comfirm if this is a bug or we're all doing
something wrong?

Thanks,
Sebastiaan

SV Billabong

unread,
Dec 29, 2009, 4:00:47 PM12/29/09
to Google AJAX APIs
The timeout hack works (thanks Sebastiaan).

Can someone from Google confirm if this is a bug or we're all doing
something wrong?

Pretty please!!

Thanks

Adam Feldman

unread,
Dec 29, 2009, 4:21:58 PM12/29/09
to Google AJAX APIs
Hello,

Ads are designed to only be shown when your site's visitors actually
perform searches of their own. Please don't attempt to circumvent
this behavior - doing so could be considered a violation of the ads
policy and be cause for suspension of access to the API.

Thanks!
Adam

SV Billabong

unread,
Jan 2, 2010, 6:39:13 PM1/2/10
to Google AJAX APIs
Adam,

I assume you work for Google.. I am using a form that posts the query
to a specific page with a CSE on it, using the q parameter to trigger
the search.

The form is a widget designed to be embedded on various blogs and the
site's visitor actually performs the search using the form.

Reply all
Reply to author
Forward
0 new messages