Skip to content

Instantly share code, notes, and snippets.

View siliconvallaeys's full-sized avatar

Frederick Vallaeys siliconvallaeys

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / Conflicting Negative Keywords for Converting Queries
Created October 9, 2018 23:21
Find negative keywords that block queries that have converted in the past
/*
// AdWords Script: Negatives Blocking Converting Queries
// -----------------------------------------------------------------------------
// Copyright 2017 Optmyzr Inc., All Rights Reserved
//
// This script identifies negative keywords that are now blocking ads from
// appearing for previously converting queries
//
// For more PPC management tools, visit www.optmyzr.com
//
@siliconvallaeys
siliconvallaeys / Analyze Close Variant Search Terms
Last active July 24, 2019 03:11
Compare phrase and exact match Google Ads keywords with the close match variants they are shown for
// Report on how close variants relate to your keywords in Google Ads
// Free AdWords Script courtesy of Optmyzr.com
// September 12, 2018
function main() {
// -----------------
// Edit this section with your preferences
// ----------------
var time = 'LAST_30_DAYS';
@siliconvallaeys
siliconvallaeys / Exclude Mobile App Placements
Last active January 14, 2020 03:10
Add poorly performing mobile app placements on GDN as excluded targets
/****************************
* Exclude Mobile App ad placements that perform poorly
* Version 1.0 (Aug 08, 2018)
*
* Created By: Optmyzr
* A supported version of this script is available at www.optmyzr.com
****************************/
function main() {