Google Custom Search API gl parameter not working

118 Views Asked by At

I am new to the CustomSearch API. I am wanting to use the gl parameter to focus my search results. I am based in the UK.

What happens is, I go to www.google.co.uk in a new incognito tab, search for football, and see bbc.co.uk, skysports.com etc. This is as expected.

If I go to www.google.com in a new incognito window, search again for football, again I see bbc.co.uk, skysports.com etc. I wasn't expecting this, but it makes sense, it must be based on my IP/Region etc.

On www.google.com, if I then open up Search Settings --> Language and region, and change results region from "current region" to "US" and go back to search I now see www.nfl.com, www.espn.com etc, which is now as expected.

Now, when using the API, I was expecting the GL parameter to mimic this behavior, but this is not the case. What am I missing? GL parameter should set the "Geolocation of end user", as per https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list.

However, what I see is NFL.com, Wikipedia, collegefootballplayoff.com, africa.espn.com - not the UK based links I was expecting.

My API looks like this: https://www.googleapis.com/customsearch/v1?key=[APIKEY]&cx=[CX]&q=football&gl=uk

I have also tried setting the Region in my Programmable Search Engine to United Kingdom and ticked Region-restricted results, which didn't help.

I want to be able to focus my users search requirements.

0

There are 0 best solutions below