Script To Eradicate Click Fraud in Google Ads

Google Ads hack, This script will loop through all your campaigns, find the targeted countries, and exclude any countries that are not Australia from your campaigns.

 

Particularly beneficial for knocking down on Google Ads click fraud where VPNs and click farms are being used.

 

Here's the script:

 

function main() {

 var targetCountry = 'Australia';

 

 var campaignIterator = AdsApp.campaigns().get();

 

 while (campaignIterator.hasNext()) {

  var campaign = campaignIterator.next();

  var locationTarget = campaign.targeting().targetedLocations();

 

  // Get all existing targeted locations

  var targetedLocations = locationTarget.countries().get();

  while (targetedLocations.hasNext()) {

   var country = targetedLocations.next();

   if (country.getName() !== targetCountry) {

    locationTarget.excludedLocations().addCountry(country.getName());

   }

  }

 }

}

 

Instructions:

 

1. Log in to your Google Ads account.

2. Go to the "Tools & Settings" menu and select "Scripts."

3. Create a new script and paste the provided code.

4. Modify the targetCountry variable if needed (though it's already set to 'Australia').

5. Review and test the script in a controlled environment by clicking on the "Preview" button.

6. Once satisfied with the preview results, click on the "Run" button to apply the changes to your campaigns.

 

Thanks,

 

Shoaib

Marketix Digital

Google Ads Script for Click Fraud