Расширенная статистика в телеграм от Google ADS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(){ | |
var currentAccount = AdsApp.currentAccount(); | |
var todayCost = AdsApp.currentAccount().getStatsFor("TODAY").getCost(); // Затраты сегодня | |
var todayClicks = currentAccount.getStatsFor("TODAY").getClicks(); // Клики сегодня | |
var todayCpc = currentAccount.getStatsFor("TODAY").getAverageCpc(); // Цена за клик сегодня | |
var todayImpressions = currentAccount.getStatsFor("TODAY").getImpressions(); // Кол-во показов сегодня | |
var tagAccounts = 'Samara53'; // Тэг аккаунта для личной статистики | |
sendTelegramMessage( | |
'\nАккаунт ID: ' + currentAccount.getCustomerId() + | |
'\nКликов сегодня: ' + todayClicks + | |
'\nПотрачено сегодня: ' + todayCost + ' ' + currentAccount.getCurrencyCode() + | |
'\nЦена за клик: ' + todayCpc + | |
'\nКол-во показов: ' + todayImpressions + | |
'\n#' + tagAccounts); | |
} | |
function sendTelegramMessage(text) { | |
var CONFIG2 = { | |
TOKEN: 'YOUR_TOKEN', | |
CHAT_ID: 'CHAT_ID' | |
}; | |
var telegramUrl = 'https://api.telegram.org/bot' + CONFIG2.TOKEN + '/sendMessage?chat_id=' + CONFIG2.CHAT_ID + '&text='; | |
var message = encodeURIComponent(text); | |
var sendMessageUrl = telegramUrl + message; | |
var options = { | |
method: 'POST', | |
contentType: 'application/json' | |
}; | |
UrlFetchApp.fetch(sendMessageUrl, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment