How to set multiple locations in DataForSEO Google Trends API
DataForSEO Google Trends API makes it easy to analyze keyword popularity globally, locally, and across multiple locations at once, each corresponding to a specific keyword. This flexibility allows you to conduct comparative analysis and gain accurate insights when targeting specific countries.
Let’s explore how to employ location_code
and location_name
parameters correctly in different use cases.
How to use location parameters in Google Trends API
In Google Trends API requests, you can use location_code
and location_name
parameters interchangeably. They allow you to specify the locations (countries) for which you want to get keyword popularity data.
1 If you omit these parameters, you will obtain global results.
{
"keywords": ["iphone", "samsung"]
}
2 To get location-specific data for a single country, use either location_code
or location_name
parameter as a string.
{
"keywords": ["iphone", "samsung"],
"location_name": "United States"
}
3 To collect data for multiple locations, use either the location_code
or location_name
parameter as an array. Note that each item in this array corresponds to a specific keyword from the keywords
array.
{
"keywords": ["iphone", "samsung"],
"location_name": ["United States", "Ukraine"]
}
In the last example, the API will return keyword popularity trends for:
➤ “iphone” in the United States;
➤ “samsung” in Ukraine.
Important things to note when setting multiple locations:
The number of locations (in location_code
or location_name
) must exactly match the number of keywords in the keywords
array. If you have 5 keywords, you should have 5 corresponding locations.
The order in which you specify locations and keywords determines their pairing. The first keyword in the keywords array will be matched with the first location in the location_name
array, and so on.
Avoid combining global searches with location-specific searches in the same request. If you try to request global data for one of the keywords while specifying locations for others, the API will return an error.
Conclusion
By using the location_code
and location_name
parameters correctly in your API requests, you can gather precise, localized keyword popularity data and tailor your strategy to specific markets. Follow the best practices outlined above to reduce errors and maximize the potential of DataForSEO Google Trends API in your SEO and marketing research.