You may have probably interacted with Little Kenya USSD code application to request a taxi and wondered, "how did they know my location, and how can I do the same for my USSD code application". If you haven't and are in Kenya, try dialling*826#on your Safaricom phone number.
Before smartphones were a thing, location tracking was still a thing. To understand how Little Kenya can do so, you first have to understand how your phone works and the concept of triangulation.
Your phone is connected to 3 (hence the name triangulation) or more boosters at any given time. A booster is the red and white mast that you might have seen on hills. As you move around, your phone is actively calculating the best signal to ensure you have the best connection.
In Kenya, Safaricom has an accurate knowledge of the position of each booster. They can therefore draw an approximate location of where you are. E.g. around Kilimani. Then based on the calculations above, they can determine that you are x distance from each of their nearest booster. From this, they can get very accurate latitude and longitude location of your phone.
Unfortunately, this capability is unavailable to every USSD code application in Kenya. USSD code application developers have been bugging service providers to enable this for them. However, your service provider cannot do this unless you deal directly with Safaricom.
You will need to make a case with Safaricom to get location tracking on your USSD code. The likelihood of getting approved is extremely low – sub-zero.
Location tracking alternative – No code
By its nature, USSD is not smart. It is a simple transfer of text and numbers of a network, similar to SMS.
For most applications, getting accurate latitude and longitude is unnecessary unless you are a taxi-hailing or delivery app like Little. You probably need a near approximation of where your client is, e.g. the nearest market or town centre.
For this scenario, you can use Google Places API to query a location based on a keyword.
Using Google Places Maps on USSD
Like the Maps application on your phone, Google offers an API to query locations via text and get possible location coordinates.
The 3 APIs available are:
Find Place API: Per the singularity of the name, this API returns a single result of the best match based on your query. E.g. if you search for KICC Nairobi, you are likely to get the following result.
Nearby search: Let's you search for places near a location.
Text search: An open search similar to searching on Google Maps or Google search.
The best API for our use case is the Find Place API. On your USSD, request a user to enter the name of a nearby landmark, query the Find Place API and confirm with them. If it's incorrect, ask them to try again with a different keyword.
Do it with HelloDuty without writing code or hiring a developer.
Brrng already offers you the ability to register your USSD application via click and config without the need to hire a developer.
We also help you extend that capability and integrate your USSD to many applications, including Google Places.