Skip to content

Instantly share code, notes, and snippets.

View siliconvallaeys's full-sized avatar

Frederick Vallaeys siliconvallaeys

View GitHub Profile
@siliconvallaeys
siliconvallaeys / Exclude Close Variants
Last active August 7, 2019 13:13
Manage close variants to automatically exclude as negative keywords
// Report on how close variants relate to your keywords in Google Ads
// Automatically exclude queries with poor performance or a big Levenshtein distance
// Free AdWords Script courtesy of Optmyzr.com
// October 22, 2018
function main() {
// -----------------
// Edit this section with your preferences
// ----------------
@siliconvallaeys
siliconvallaeys / Match Type Performance Report
Last active January 14, 2020 03:18
Get aggregate performance data by keyword and search term match type
// Create a report in a Google spreadsheet with performance data by keyword match type and search term match type in Google Ads
// Free AdWords Script courtesy of Optmyzr.com
// October 22, 2018
var DEBUG = 0;
function main(){
var currentSetting = new Object();
@siliconvallaeys
siliconvallaeys / Bing Ads - Account Quality Score
Created November 7, 2018 01:42
Calculate an impression weighted quality score average for a Bing Ads PPC account
function main() {
var time = "LAST_30_DAYS";
var totalImpressions = 0;
var totalQs = 0;
var iterator = BingAdsApp.campaigns().forDateRange(time).withCondition("Impressions > 0").get();
while(iterator.hasNext()) {
var campaign = iterator.next();
@siliconvallaeys
siliconvallaeys / Send Email With Bing Ads Scripts
Created November 8, 2018 16:23
Use SendGrid's API to send emails from Bing Ads Scripts
function main() {
// Get your own SendGrid API Key from https://app.sendgrid.com/settings/api_keys
var SENDGRID_API_KEY='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';
var emailTo = "example@example.com";
var subject = "About your Bing Ads account";
var emailBody = "Now you can send emails using Bing As Scripts. Thanks Optmyzr for the code sample!";
var headers = {
@siliconvallaeys
siliconvallaeys / Save Json for Bing Ads Scripts
Created November 8, 2018 16:37
Write JSON data to a public store for saving state about a Bing Ads Script automation - for example to create virtual 'labels'
function main() {
// Enter your own URL here - get it from http://myjson.com
var MyJsonBin = 'https://api.myjson.com/bins/l46me';
// This is the object you will store for use the next time the script runs
var dataToStore = {};
dataToStore.lastKeywordProcessed = "some keyword";
dataToStore.someOtherThingToTrack = "the other thing's ID is 123456";
@siliconvallaeys
siliconvallaeys / Read Json for Bing Ads Scripts
Created November 8, 2018 16:43
Read data from a public Json data store so you can maintain state between several script runs
function main() {
// Enter your own URI here, the same one you used when writing your data
var MyJsonBin = 'https://api.myjson.com/bins/l46me';
var options = {
method:"get",
};
var response = UrlFetchApp.fetch(MyJsonBin, options);
@siliconvallaeys
siliconvallaeys / Monthly Account Budgets for Bing Ads
Last active December 12, 2018 20:53
Pause campaigns when an account exceeds its target monthly Bing Ads budget
var MAX_COST = 100000; // Max allowed account cost for the month
var MYJSONBIN = 'https://api.myjson.com/bins/xyzxyz'; // Get your own URL from http://myjson.com
var SENDGRID_API_KEY = 'SG.ghadha.xEYjNvhGEZMvfAZT4IGR7_CR73p5VU0ZC3UFasv8oys'; // Get your own API key from https://sendgrid.com
var EMAIL_ADDRESS = 'example@example.com'; // Sends notifications to this email
var EMAIL_FROM = 'example@example.com'; // Sends notifications from this email
function main() {
var account = BingAdsApp.currentAccount();
@siliconvallaeys
siliconvallaeys / Ad Component Report
Last active April 24, 2019 06:26
Aggregated metrics for the various ad text elements used in an account
// Create a report in a Google spreadsheet with performance data by ad component
// Metrics for each unique headline, description, path, and visible URL are aggregated
// Use this data to find the best ad components for use in new ads or responsive search ads
// Free AdWords Script courtesy of Optmyzr.com - try Optmyzr for more PPC tools and scripts
// January 2019
function main() {
var currentSetting = {};
currentSetting.spreadsheetUrl = "NEW";
currentSetting.time = "LAST_30_DAYS";
@siliconvallaeys
siliconvallaeys / Ad Text N-Grams
Last active March 5, 2023 13:25
Get an n-gram analysis of Google Ads ad texts
/**
*
* Ad Text N-Gram Mining Tool
*
* Get aggregated metrics for when the same word sequence is used in ads across your account.
* Discover better performing phrases from all your Google Ads.
*
* Based on a script by Daniel Gilbert and BrainLabsDigital.com (https://searchengineland.com/brainlabs-script-find-best-worst-search-queries-using-n-grams-228379)
*
* Adapted by Fred Vallaeys and Optmyzr.com to work with expanded ad text rather than search terms data
@siliconvallaeys
siliconvallaeys / Ad Component Report with Segments
Created February 13, 2019 00:26
Ad component report for Google Ads with segment data
// Create a report in a Google spreadsheet with performance data by ad component
// Metrics for each unique headline, description, path, and visible URL are aggregated
// Use this data to find the best ad components for use in new ads or responsive search ads
// Free AdWords Script courtesy of Optmyzr.com - try Optmyzr for more PPC tools and scripts
// February 2019
function main() {
var currentSetting = {};
currentSetting.spreadsheetUrl = "NEW";
currentSetting.time = "20180101,20190201"; //"LAST_30_DAYS", "LAST_MONTH", "20180101,20181231"