near me

Google UULE parameter – a 2020 guide to geolocation

by Valentin Pletzer - June 7th, 2020

The goal of this article is to explain how the UULE parameter in Google Search works. A lot of tools, including the Google Adwords Tool, use it to emulate a physical location of a searcher.

What it’s for and how to use

The Google UULE parameter is used to encode a place or an exact location (with latitude and longitude) into a value used in a cookie, an url or an http header. By making use of this you can see a Google result page like someone located at the specified location.

There are two known versions of the UULE parameter: One beginning with “w+CAIQICI…” and one with “a+cm9…”. Both can be found as a cookie value UULE for www.google.com but also as a get-parameter in the url. In addition to that it can be also found as a http header “x-geo” used by the Google app. While the cookie and url parameter often are used with the “w+CAIQICI…” version both version are accepted by the Google servers in all forms as valid means to alter the location.

Version 1: w+CAIQICI…

The more common version of the two is probably used by most tools out there as a url parameter to place a search at a location. In this version a “canonical name” is used which is typically used by Google AdWords to geotarget ads. You can find a regularly updated csv file of geotargets in the reference section of the Google AdWords. An example of such a canonical name is “West New York,New Jersey,United States” which consists of the name of the place, a region and the country where the place is located.

I can’t be sure what the meaning of the first character is but for now we simply will continue and will try to reveal it’s secrets. What I can tell you is that to decode it correctly you have to handle the whole string as a URI component and decode it, split the string by the "plus" and base64-decode the second part of the string (the one beginning with “CAIQICI”).

This is where most articles out there fall short of a precise explanation. A typical tutorial will tell you to split the string into “w+CAIQICI”, a “string key” you have to calculate and a base64 encoded “canonical name”. While this works this isn’t really how it is done.

If you decode the whole string you will end up with a binary which really is a protocol buffer file used everywhere by Google. If you decode this raw protocol buffer you will end up with a representation which looks like this:

1: 2
2: 32
4: "West New York,New Jersey,United States"

As you can see there are three fields (1, 2 and 4) which we don’t know the meaning but we can guess. Field 1 is most probably the version (or role) of the data and field 2 is an enumeration of producers, so 32 is identifying maybe AdWords as a source of the canonical name. Field 4 finally is the canonical name of the location.

Since we now have reverse engineered a first version of the whole uule parameter we now can write a small program allowing us to encode and decode it.

try it: Google Search

Version 2: a+cm9…

This version can be found in the cookie which Google writes after getting the location via the Geolocation API on the website. This is also the version I used in my Chrome extension gs location changer, because this version requires no guessing of fields.

After seeing the output of this version there is a slight assumption that the letter a is most likely short for ascii, since this version doesn’t use protocol buffer but text. If you url-decode the string and then base64-decode it afterwards you will not get binary data but ascii text which looks like this:

role:1
producer:12
provenance:6
timestamp:1591466554310000
latlng{
latitude_e7:373860520
longitude_e7:-1220838510
}
radius:93000

Reading this text of course is much more self-explanatory than the lite version a protocol buffer provides even though we don’t have a list of valid values for role, producer and provenance. Timestamp of course is a high precision variant of the the time elapsed since January 1, 1970 00:00:00 UTC (milliseconds times 1000).

Latitude and longitude are both 1e7 encoded values of the float notation usually used. Most probably to get an signed integer instead of a float value. So to convert these values you have to divide the integer by 10,000,000 to get the float or multiply the float to get the integer.

Last but not least there is the radius which according to the Google Maps API reference documentation is “The distance (in meters) within which to return place results.” but given what I have seen for UULE the radius value is meters times 620. The radius is probably needed because even though modern geolocations are a showcase of technical ingenuity there is always some fuzziness to it.

By the way: You could also specify -1 as a value for radius, meaning that you provided the exact coordinates yourself. The value for “role” then should be “USER_SPECIFIED_FOR_REQUEST” and “producer” is “LOGGED_IN_USER_SPECIFIED”.

Now we have successfully reverse engineered the second type of UULE we can encode and decode this as well.

try it: Google Search

feedback welcome

If you like this article, experience any problems, have ideas for upgrades or just want to say hi, feel free to contact me on Twitter @VorticonCmdr.