Change History Alerts Google Ads Script

PPC

If you’re managing Google Ads accounts for clients, you know the importance of monitoring changes. A small adjustment from an external team member can have a huge impact, and if you’re not keeping a close eye, it’s easy to miss.

To make this easier, I’ve built a change history Google Ads script that alerts you via email whenever there’s an unapproved change in your accounts. Below, I’ll share the script itself, along with step-by-step instructions on setting it up so you can use it too.

Here’s an example of the alert it would produce:

*Some information in image above hidden to protect client privacy

Why Use a Change History Google Ads Script?

The change history tool in Google Ads is an essential way to track every adjustment. However, it requires manually checking the log, which is time-consuming if you manage multiple accounts. This is where automation can make life easier.

This script runs daily, monitors changes in Google Ads, and emails you a summary whenever there’s a change from someone outside your list of recognised users. It’s simple, it’s efficient, and it keeps you in the loop—letting you focus on optimising campaigns, not chasing down unexpected changes.

How the Script Works

By default, this change history Google Ads script:

1. Scans recent changes in your account from the last 7 days.

2. Filters users based on a list of approved email addresses.

3. Sends a scheduled email summarising unapproved changes, with the date, user, and number of changes.

Weekly vs Daily Alerts

The script is set to check the last 7 days by default, but if you’d prefer daily alerts, it’s easy to modify. Just change the PERIOD variable from "LAST_7_DAYS" to "YESTERDAY". This way, your script will check changes from only the last 24 hours, making it perfect for daily monitoring.

Setting Up the Change History Google Ads Script

Here’s the script along with instructions on setting it up in your Google Ads account:

/**
* Change History Alerts
*
* This script checks all entries in the Google Ads change history of your account.
* If there's a change by a user outside of your list of 'recognised' users,
* an alert email is sent with the number of changes, grouped by user and date.
*
* Version 1.5
*/

// CHANGE SETTINGS HERE

var EMAIL_ADDRESSES = "your.email@example.com"; // alert email addresses
var IGNORE_USERS = [
    'your.email@example.com',
    'team.member@example.com',
    'trusted.agency@example.com',
    'Bulk Actions',
];

var SEND_EMAIL = true;
var PERIOD = "LAST_7_DAYS";

function main() { 
    Logger.log("Processing account: " + AdsApp.currentAccount().getName());
    var changeAlerts = getChangeAlerts();
    
    if (changeAlerts.length > 0) { // Send alert if there are any changes
        sendEmail(changeAlerts);
    } else {
        Logger.log("No unrecognised user changes found in the last " + PERIOD);
    }
}

// Look into change history and return changes to add to alert report
function getChangeAlerts() {
    var changes = [];
    var query = "SELECT " +
                "change_event.change_date_time, " +
                "change_event.user_email " +
                "FROM change_event " +
                "WHERE change_event.change_date_time DURING " + PERIOD + " " + 
                "AND change_event.user_email NOT IN ('" + IGNORE_USERS.join("', '") + "') " +
                "ORDER BY change_event.change_date_time DESC " + 
                "LIMIT 9999";
    
    try {
        var result = AdsApp.search(query);
    } catch (e) {
        Logger.log("Issue retrieving results from search API: " + e);
    }
    
    while (result.hasNext()) {
        var row = result.next();
        var change = {
            date: formatDate(row.changeEvent.changeDateTime),
            user: row.changeEvent.userEmail
        };
        changes.push(change);
    }
    
    return changes;
}

// Formats the date to DD-MM-YYYY HH:MM
function formatDate(dateString) {
    var date = new Date(dateString);
    var day = ('0' + date.getDate()).slice(-2);
    var month = ('0' + (date.getMonth() + 1)).slice(-2);
    var year = date.getFullYear();
    var hours = ('0' + date.getHours()).slice(-2);
    var minutes = ('0' + date.getMinutes()).slice(-2);
    
    return day + '-' + month + '-' + year + ' ' + hours + ':' + minutes;
}

// Sends an email with a summary of changes grouped by user and date
function sendEmail(changeAlerts) {
    var accountName = AdsApp.currentAccount().getName();
    
    if (SEND_EMAIL) {
        var userSummary = {};
        
        // Group changes by user and date
        changeAlerts.forEach(change => {
            if (!userSummary[change.user]) userSummary[change.user] = {};
            if (!userSummary[change.user][change.date]) userSummary[change.user][change.date] = 0;
            userSummary[change.user][change.date]++;
        });
        
        // Compose the email body
        var emailBody = "Detected changes by external users in account: " + accountName + "\n\n";
        
        for (var user in userSummary) {
            emailBody += "User: " + user + "\n";
            for (var date in userSummary[user]) {
                emailBody += "  - Date: " + date + " - Changes: " + userSummary[user][date] + "\n";
            }
            emailBody += "\n";
        }
        
        MailApp.sendEmail(EMAIL_ADDRESSES, "[GAds Script] - ALERT - Change by External User in " + accountName, emailBody);
        Logger.log("Alert email sent.");
    }
}

Step-by-Step Setup

  • Create a new Google Ads script:

    • In your Google Ads account, go to Tools & Settings > Bulk Actions > Scripts.

    • Click the + button to create a new script.

  • Paste the Script:

    • Copy the script above and paste it into the script editor.

    • Update the EMAIL_ADDRESSES variable with your preferred email addresses.

    • Add any trusted emails to the IGNORE_USERS list, so the script will only alert you about changes from unapproved users.

  • Set the Period:

    • By default, PERIOD is set to "LAST_7_DAYS" for weekly change tracking.

    • The available time periods are limited to pre-defined options like "LAST_7_DAYS", "TODAY", or "YESTERDAY". For daily tracking, you can set PERIOD to "YESTERDAY" instead, which will check changes from the previous day each time the script runs.

  • Run the Script:

    • Save your script with a meaningful name.

    • Run the script manually once to check for any errors.

    • If everything runs smoothly, set it up on a daily or weekly schedule under Script Settings to receive alerts on your preferred schedule.

  • Check Your Email:

    • Once it’s scheduled, check your email for alerts about unapproved changes. The email will show each user and date, along with the number of changes they made.

Why This Change History Google Ads Script is a Game-Changer

With this simple change history Google Ads script, you can:

Save Time: No more manual checks! Your inbox becomes the only place you need to look for updates.

Gain Control: You’re instantly aware of any adjustments, so you can act quickly to protect account performance.

Focus on Optimisation: With automation handling change monitoring, you can spend more time refining campaigns and less time on admin.

If you’re looking for a way to streamline your Google Ads management, this change history Google Ads script is a quick win. Let me know if you have questions, or feel free to share how this works for you!

Next
Next

Weird GA4 Referral Traffic From news.grets.store, & static.seders.website? Here’s Why & What To Do.