Competitor keywords for Google Ads using the Bukvarix API

Modified version of getting competitor keywords for the script from the original article — «Google Ads campaign based on competitor keywords«. I wrote it for local hobby projects.

The Bukvariks API, in comparison with the Similarweb API, has a couple of features that may be useful for some advertisers:

  1. Bukvariks better «sees» the Russian segment of the Internet
  2. They have a limited but free API usage plan.

To use it, we need to replace the function in the original script get_keys(). It starts at the moment when you have already created a campaign, and it has ad groups where the competitor’s domain is specified as the name of the group.

Here is the code:

function get_keys(domain) {
    var api_key = 'free';
    var results = 1000;
    var regionArr = [
     'msk', // (Yandex Moscow)
     'gmsk', // (Google Moscow)
     'spb', // (Yandex Saint Petersburg)
     'rus', // (Yandex Russia)
     'gkiev', // (Google Kyiv)
     'minsk', // (Yandex Minsk)
     'gminsk', // (Google Minsk)
     'nursul' // (Yandex Nur-Sultan)
  ];

    var arr = [];
    for (var y = 0; y < regionArr.length; y++) {
        Utilities.sleep(1000);
        var region = regionArr[y];
        var url = `http://api.bukvarix.com/v1/site/?q=${domain}&api_key=${api_key}&num=${results}&format=json&region=${region}`;
        var response = UrlFetchApp.fetch(url);
        var json = JSON.parse(response.getContentText());
        for (var w = 0; w < json.data.length; w++) {
            arr.push([json.data[w][0]]);
        }
    }
    return unique(arr);
}

function unique(arr) { // remove duplicates
    var tmp = {};
    return arr.filter(function (a) {
        return a in tmp ? 0 : tmp[a] = 1;
    });
}

All settings are specified directly in the function body. If you pay for the service, you will need to replace the API key and the limit for the desired number of lines in the service’s response.

The function will go through all available geos in turn and collect a general list of keywords.


Добавить комментарий