Google Ads script - Notify me when a change is being made by another user than me

617 views
Skip to first unread message

Dinant Lagerweij

unread,
Feb 2, 2023, 7:42:51 AM2/2/23
to Google Ads Scripts Forum
With the help of ChatGPT I built a script that notifies me when a change is being made by another account than us.

Should this work? I'm not experienced with scripts.

_________________________

// This script sends an email alert when changes are made to the account that are not made by a user with an email address that consists of "@webleads.nl".

// Get the account's changes.
var accountChanges = AdWordsApp.currentAccount().getChanges();

// Check each change to see if it was made by the specified user.
for (var i = 0; i < accountChanges.length; i++) {
  var change = accountChanges[i];
  if (!change.getLastModifiedBy().endsWith("@webleads.nl")) {
    // Send an email alert.
    MailApp.sendEmail("your-...@example.com", "Unauthorized account change detected", "A change was made to the account by " + change.getLastModifiedBy() + " at " + change.getLastModifiedDate());
  }
}

Google Ads Scripts Forum

unread,
Feb 7, 2023, 2:12:18 AM2/7/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/2bR6NT-h7zo) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Feb 7, 2023, 2:53:31 AM2/7/23
to Google Ads Scripts Forum
Hi,

Thank you for reaching out to us. This is Yasmin from the Google Ads Scripts Team. Please excuse us for only getting back now as your message failed to be routed to our support queue.

You can refer to the Google Ads Scripts documentation for reference on the available methods which can currently be used in Google Ads Scripts. Kindly note that there isn't a getChanges() method for AdsApp.​Account, as well as a getLastModifiedBy() method which can be used with the aforementioned tool.

That being said, you could make use of Reporting and report on the change_event report type. You can check this link for an example of an implementation when reporting. To give some information on the report type, this describes the granular change, however, it is only of the returned resource of certain resource types. Changes made through UI, API and new versions of Editor by external users (including external users, and internal users that can be shown externally) in the past 30 days will be shown. The change shows the old values of the changed fields before the change and the new values right after the change. ChangeEvent could have up to 3 minutes delay to reflect a new change.

Let us know if you have any further clarifications.


Regards,
Yasmin
Google Ads Scripts Team

Nils Rooijmans

unread,
Jan 5, 2024, 9:59:08 AM1/5/24
to Google Ads Scripts Forum
here's a script that probably fixes your needs:
Reply all
Reply to author
Forward
0 new messages