Skip to content

Instantly share code, notes, and snippets.

View postman31's full-sized avatar

Dmytro Bulakh postman31

View GitHub Profile
@postman31
postman31 / weighed_qs_report.js
Last active February 20, 2020 15:19
Impressions-weighed Quality Score report
/*
This script produces Impressions-weighed Quality Score report in G-sheet for Top X Ad Groups,
paired with key performance metrics
Report is based on Historical Quality Score records
Script uses three custom user defined slots for Quality Score: Low, Mid and High
*/
// Options section:
// cunstom function
function () {
var divList = document.querySelectorAll('.bx-soa-section-content div')
var content = Array.prototype.reduce.call(divList, function(res, el, ind) {if (el.innerText != '') { var s = el.innerText.split(/\:\s*/); res['field_'+ind] = s[1];} ; return res }, {} )
return content['field_1'] // chose other index for the necessary field
}
// dataLayer
var divList = document.querySelectorAll('.bx-soa-section-content div')
@postman31
postman31 / Dissaproved Extensions Report.js
Last active February 11, 2022 04:30
Dissaproved Extensions Report Script
/*
Disapproved Extensions Report Script.
This scripts generates an email if there are some non-removed disapproved extensions.
Disapproval reasons are taken from PLACEHOLDER_FEED_ITEM_REPORT.
Check the nameMapping veriable below for the list of supported extensions.
Email message could also include a long list of dissaproved remarketing feed items, so adjust settings to skip this if necessary.
Developed by Dmytro Bulakh, 2020, bulakh@ppchead.com
*/
@postman31
postman31 / leads_to_sheet.js
Last active March 23, 2024 12:56
Sample Script to store your leads from lead form extension to Google Sheet
/*
Sample script to be used as a webhook listener for Google Ads Leads Campaigns
## Setup:
1) Create a new script project at https://script.google.com/ and paste the script code into the editor window
2) Create a new scpreadsheet and paste the URL in lines #15 and #65
3) in the menu above select Init function and make a first run to initialize authorization process (https://nimb.ws/WnvXJz)
4) publish the script as a web app through the `Publish > Deply as a web app` menu. Make sure set
the "Who has access to the app:" option to "Anyone, even anonymous"
5) use generated link as a webhook URL in Google Ads form settings
@postman31
postman31 / ads_report_aggregation.js
Created October 23, 2019 10:34
Aggregation function for Ads Script Reports
function report2Set(query, idKey, optArgs) {
var reg = /SELECT\s+(.+)\s+FROM.*/
var list = query.match(reg)
if (!list && !list[1]) throw 'Error parsing parameters from %q'.replace('%q', query)
list = list[1].replace(/\s+/, '').split(',')
if (list.length < 1) throw 'Error parsing parameters from %q'.replace('%q', query)
if (typeof idKey == 'string') {
if (!idKey.match(/id/i)) throw 'Bad idKey argument %id'.replace('%id', idKey)
if (list.indexOf(idKey) == -1) throw '%id not founf in %q parameters'.replace('%q', query).replace('%id', idKey)
}
function main() {
var budgetOrderIterator = AdWordsApp.budgetOrders()
.withCondition("Status = ACTIVE")
.get();
while (budgetOrderIterator.hasNext()) {
var budget = budgetOrderIterator.next();
Logger.log('getName %s, getSpendingLimit %s, getStartDateTime %s',
budget.getName(), budget.getSpendingLimit(), budget.getStartDateTime())
}
var available = budget.getSpendingLimit()
@postman31
postman31 / gist:601d7bb36bd8a6e08e92390ef6044c0a
Created February 19, 2019 12:56
string to nested object
var plain = {
'data.analytics.name': 'coehn',
'data.analytics.role': 'ninja'
}
var converted = function (plainObj) {
var converted = {}
for (var plainKey in plainObj) {
var nextStep = converted
var splitted = plainKey.split('.')
@postman31
postman31 / override_push.js
Created October 17, 2018 09:51
training push override
var someArray = []
someArray.push = function (element){
//Do what you want here...
if (element) {
console.log (element)
}
return Array.prototype.push.apply(this,arguments);
}
@postman31
postman31 / extensions_checker.gs
Last active January 14, 2022 06:17
The script checks for adgroups and campaigns with no particular extensions
//Options setcion
var OPTIONS = {
'REPORT_URL': '', // url of existing report sheet. leave empty string to create new report when script runs
'LOOKBACK': '', // optional lookback for items selectors that picks non removed items in loookback period. Defolts to 'LAST_7_DAYS'
'EXTENSIONS': ['sitelinks', 'callouts', 'snippets'], // list of extnesions to check. Defaults to ['sitelinks', 'callouts', 'snippets', 'phoneNumbers']
'FORCE_CHECK': true // If true will report if adgroup doesn't contain particular extension but it's available at campaign level. Defaults to false
}
function getOptions () {
var options = {}
@postman31
postman31 / GTM notifikator.gs
Created August 1, 2018 10:34
Notifies you about pending changes in your GTM workspaces by email
function myFunction() {
try {
var message = ''
var response = TagManager.Accounts.list()
response.account.map(function(account) {
Logger.log('fetching changes for %s', account.name)
var containers = TagManager.Accounts.Containers.list(account.path)
Utilities.sleep(5000)
if (!containers.container) {
Logger.log('no containers for %s', account.name)