Giới thiệu Google Suggest
Google Suggest là một tính năng có sẵn trên thanh công cụ tìm kiếm Google, nó giúp người dùng có thể nhanh chóng hoàn thiện câu lệnh của từ khóa dựa trên những tin tức nổi bật. Các kết quả tìm kiếm có thể khác nhau, nhưng hầu hết nó sẽ tập trung khai thác từ khóa mà bạn tìm kiếm trên đây, những gợi ý này sẽ giúp bạn tìm kiếm thông tin chính xác mà bạn cần.
Với bài hướng dẫn sau đây, bạn có thể nhập từ khóa mục tiêu , quốc gia và ngôn ngữ của mình, nó sẽ trả về các từ khóa câu hỏi được Google tự động đề xuất có liên quan đến từ khóa mục tiêu của bạn.
Cách 1:
Truy cập https://docs.google.com/spreadsheets/d/1TbEhqMUH9tmiWw7aC3rTJ7DllFFWAcqbGyc6ZMOOIs4/copy tạo 1 bản sao
Click vào ô Question để thay đổi thông số hoặc sử dụng đoạn mã sau để kiểm tra hoạt động:
=keywordQuestions("iphone","vn","vi")
Cách 2:
Bước 1: Tạo mới trang tính https://sheets.new
Bước 2: Vào mục Tiện ích mở rộng → App Script dán đoạn mã sau:
/**
* Get Google auto suggested questions for any keyword, across any language.
*
* @param {"London"} keyword input the keyword(s).
* @param {"UK"} country input the country.
* @param {"en"} language input the language.
* @return auto suggested questions from Google Search.
* @customfunction
*/
function keywordQuestions(keyword, country, language) {
// translate language from english to input language
const translate = (question, language) => {
try {
return LanguageApp.translate(question, 'en', language);
} catch (e) {
throw new Error("Invalid language");
}
}
const questions = ["what", "who", "where", "when", "why", "which", "how", "can", "are", "will"];
let keywords = [];
// loop through questions and fetch Google predicted queries for keyword
for (i = 0; i < questions.length; i++) {
let translateQuestions = (language !== 'en') ? translate(questions[i], language) : questions[i];
const response = UrlFetchApp.fetch("http://suggestqueries.google.com/complete/search?&output=toolbar&hl=en&q=" + translateQuestions + "+" + keyword + "&gl=" + country);
const xml = response.getContentText();
const doc = XmlService.parse(xml);
const suggestions = doc.getRootElement().getChildren('CompleteSuggestion');
// loop through output xml and push Google keyword predictions to array
for (j = 0; j < suggestions.length; j++) {
const suggestion = suggestions[j];
const data = suggestion.getChild('suggestion').getAttribute('data').getValue();
keywords.push([translateQuestions, data]);
}
}
keywords.unshift(["Question", "Search Query"]);
return keywords;
}
Lưu ý: Kết quả mang tính chất tham khảo từ Google Suggest
Nguồn tham khảo: Google autosuggested questions for any keyword, across any language - Keywords in Sheets