Skip to content

Instantly share code, notes, and snippets.

View adhummer's full-sized avatar

strayr adhummer

View GitHub Profile
@adhummer
adhummer / gist:f33e23d3f5a9264883cb94c96971e85d
Created December 29, 2019 16:59
Google Tag Manager / Wordpress Contact 7 - Listener Tag for GTM
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
window.dataLayer.push({
"event" : "cf7submission",
"formId" : event.detail.contactFormId,
"response" : event.detail.inputs
})
});
</script>
@adhummer
adhummer / Google Analytics Opt-Out.html
Last active May 4, 2019 08:24
Google Analytics Opt-Out
<script>
var gaProperty = 'XXXXXX';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
function main() {
var date_range = 'THIS_MONTH';
//Change this variable to whatever your account level monthly budget is to be.
//If you have a hard limit of total Cost in a month of $1,000.00
//then you would change the value to 1000.
var total_monthly_budget = '1000';
var currentAccount = AdWordsApp.currentAccount();
var stats = currentAccount.getStatsFor(date_range);
var accountName = currentAccount.getName();
Logger.log('Cost this month to date: $' + stats.getCost());
@adhummer
adhummer / gist:80afdcb0145c051bb11e3c5fdf824f11
Created September 19, 2016 09:30
Hard Cap, pause campaigns
function main() {
// GET THE TOTAL SPEND OF THE ACCOUNT
// https://developers.google.com/adwords/scripts/docs/reference/adwordsapp/adwordsapp_keywordselector
var costReport = AdWordsApp.report("Select Cost from ACCOUNT_PERFORMANCE_REPORT");
var reportRow = costReport.rows().next();
var totalCost = reportRow["Cost"].replace(',', ''); // Remove thousand separator
var costReport = AdWordsApp.report("Select Cost from ACCOUNT_PERFORMANCE_REPORT DURING THIS_MONTH");
@adhummer
adhummer / Daily Healthy Check Impression v1
Created June 12, 2015 15:23
Daily Healthy Check Impression v1
// EMAIL FIELDS
var _mailto = '[email protected]';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 1;
var _clickTreshold = 0;
var _conversionTreshold = 0;
@adhummer
adhummer / Daily Healthy Check v1
Created January 28, 2015 16:03
Daily basic health check for adwords accounts
// EMAIL FIELDS
var _mailto = 'YOUR EMAIL';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 1;
var _clickTreshold = 0;
var _conversionTreshold = 0;
var workingDateRange = "LAST_14_DAYS";
function main() {
lowerBidsToTopKeywords();
raiseBidsToMidPositionKeywords();
raiseBidsToLowPositionKeywords();
}
// EMAIL FIELDS
var _mailto = 'YOUR_EMAIL';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 100;
var _clickTreshold = 10;
var _conversionTreshold = 2;
// EMAIL FIELDS
var _mailto = 'YOUR_EMAIL';
var _subject = 'Account Review Needed - ';
var _htmlBody = '<h1>Account Review Required</h1>';
var _isEmailRequired = false;
//PARAMETERS CHECKED
var _impressionsTreshold = 100;
var _clickTreshold = 10;
var _conversionTreshold = 2;
//Edit this based on the max amount you want to spend on a given day.
var maxSpend = 1000;
function main () {
var currentAccount = AdWordsApp.currentAccount();
var stats = currentAccount.getStatsFor("TODAY");
var cost = stats.getCost();
Logger.log("Account has spent " + cost + " so far.");
if (cost > maxSpend) {
campaign.pause();