HomeFree toolsSuffix checker
Google Ads script

Suffix checker (UTM tracking template)

Sets a tracking template on all active campaigns — Search, Shopping and Performance Max — so every click is auto-tagged with UTM (utm_source=google, utm_medium=cpc, utm_campaign=campaign name). Skips paused/removed and logs old vs new template. Note: overwrites any existing tracking template.

By the SEOZ team · Updated June 12, 2026

All scripts
Why it helps

Why it helps: Google Ads auto-tagging (GCLID) doesn't always line up with GA4 — some paid clicks land as google / organic (Organic Search) instead of google / cpc (Paid Search), even though the traffic is actually paid. Manual UTM tagging via this script minimizes the error. In some cases 15–20% of traffic was mis-attributed to that source/medium before it was tagged manually.

Modifies account
function main() {
  // Define base UTM parameters
  var UTM_SOURCE = 'utm_source=google';
  var UTM_MEDIUM = 'utm_medium=cpc';

  // Get all campaigns, including Shopping and Performance Max
  var campaignIterators = [
    AdsApp.campaigns().get(),
    AdsApp.shoppingCampaigns().get(),
    AdsApp.performanceMaxCampaigns().get()
  ];

  // Loop through all campaigns
  for (var i = 0; i < campaignIterators.length; i++) {
    var campaignIterator = campaignIterators[i];

    while (campaignIterator.hasNext()) {
      var campaign = campaignIterator.next();

      // Skip campaigns that aren't active
      if (campaign.isPaused() || campaign.isRemoved()) {
        Logger.log('Skipping inactive campaign: ' + campaign.getName());
        continue;
      }

      var campaignName = encodeURIComponent(campaign.getName());
      var finalUrlSuffix = UTM_SOURCE + '&' + UTM_MEDIUM + '&utm_campaign=' + campaignName;
      var newTrackingTemplate = '{lpurl}?' + finalUrlSuffix;
      var oldTrackingTemplate = campaign.urls().getTrackingTemplate();

      Logger.log('---');
      Logger.log('Active campaign ID: ' + campaign.getId());
      Logger.log('Campaign name: ' + campaign.getName());
      Logger.log('Old tracking template: ' + (oldTrackingTemplate ? oldTrackingTemplate : 'None'));
      Logger.log('New tracking template: ' + newTrackingTemplate);

      campaign.urls().setTrackingTemplate(newTrackingTemplate);
    }
  }
}
How to run the script
  1. Google Ads → Tools → Bulk actions → Scripts.
  2. Click + and paste the code. Authorize when asked.
  3. Run a preview first and read the log.
  4. Schedule the script if you want it to run regularly.

This script changes your campaigns — test on a small account first.

SEOZ runs these checks for you — automatically, with alerts when something breaks.
Try the guided demo →More scripts