On my site I get the error :

Uncaught TypeError: google.search.Search.apiary15400 is not a function

where the number changes on each page refresh.

I've already checked here: https://productforums.google.com/forum/#!topic/customsearch/CYN9lFK46hk, but did not find any double cse references in my own code.

Also, the ads that are being shown on the result page are somehow lightly grayed out.

I tried adding the script code to the head of the googlesearch.aspx page and the cse tag in the body, but that results in the same error.

How I inject the code:

in head:

<script type="text/javascript">
    (function () {
        var cx = '014868809914487598599:qtooouruo1q';
        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);


in body:



Why is this happening?

1 Answer 1


You're loading the script twice, causing the function to run twice and produce this error. An example line that is doubled up:

<script type="text/javascript" async="" src="https://www.google.com/cse/cse.js?cx=014868809914487598599:qtooouruo1q"></script>

It's not the only line that's doubled - perhaps check your code for duplicates. Or if it's being injected check your document write calls to see if they've been doubled up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.