Skip to content

Instantly share code, notes, and snippets.

View siliconvallaeys's full-sized avatar

Frederick Vallaeys siliconvallaeys

View GitHub Profile
@siliconvallaeys
siliconvallaeys / gist:05ddc05c019bb2430386dae9f6b66367
Created September 9, 2016 01:14
Track AdWords Account, Campaign, and Ad Group Quality Score
// Account, Campaign, and Ad Group Level Quality Score
// -------------------------------------------------
// Script created by Frederick Vallaeys
// Optmyzr - http://www.optmyzr.com http://www.optmyzr.com/enhanced-scripts-for-adwords
// Copyright 2012-2016 - Optmyzr Inc.
//
function main() {
/*
// AdWords Script: Check If Accounts Have Automatically Added Ads
// ---------------------------------------------------------------
// Copyright 2017 Optmyzr Inc., All Rights Reserved
//
// This MCC level AdWords Script reports which accounts have
// ads with the label "Added by AdWords", indicating that
// Google is automatically testing new ad variations.
// Users can then go to the impacted accounts and search for the
// label and decide whether or not to keep these new ads.
@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 / v1.js
Created April 14, 2016 18:50
Set AdWords Budgets To Meet Monthly Targets With Day Of Week Allocation
// Copyright 2015, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@siliconvallaeys
siliconvallaeys / Aggregate Spreadsheet Data By Week or Month.js
Created March 16, 2017 18:00
This Google App Script will aggregate call data from CallRail on a Google Sheet. You can use Zapier to populate data about individual calls on a Google Sheet. Then use this code to aggregate the individual call data by week or month. You may need to edit the code to match your column headers.
var AGGREGATION_RANGE = "month";
function updateAggregateData() {
var dataSheetName = "Raw Data";
var reportSheetName = "For Reports";
var timeAggregatedData = new Array();
var answeredCalls = 0;
var notAnsweredCalls = 0;
@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";