Google Ads script template

Copy a Google Ads final URL suffix script skeleton that reads verified link state first.

This template is for teams that already know scripts should not mutate campaigns from raw spreadsheet guesses. It fetches verified Link Peeler rows, skips unsafe conclusions, and keeps mutation logic behind an explicit dry-run gate.

Direct answer

How should a Google Ads final URL suffix script start?

A safer Google Ads final URL suffix script should fetch verified row state, skip failed or unverified rows, log the exact campaign and suffix decision, and run in dry-run mode until operators confirm the eligible update set.

Copyable artifact

Copy the script skeleton.

Replace the verified rows endpoint, token, campaign lookup, and mutation block with your account-specific implementation. Keep DRY_RUN true until logs match the intended campaign update set.

javascript Google Ads Script skeleton
// Link Peeler final URL suffix sync skeleton.
// Adapt CONFIG before running in a Google Ads Scripts account.

var CONFIG = {
  VERIFIED_ROWS_URL: "https://your-link-peeler.example/api/verified-rows",
  API_KEY: "replace-with-read-token",
  DRY_RUN: true
};

function main() {
  var rows = fetchVerifiedRows();
  rows.forEach(function(row) {
    if (row.conclusion !== "valid" || !row.finalUrlSuffix) {
      Logger.log("skip row " + row.rowId + " because conclusion=" + row.conclusion);
      return;
    }

    Logger.log("ready campaign=" + row.campaignName + " suffix=" + row.finalUrlSuffix);

    if (!CONFIG.DRY_RUN) {
      // Replace this block with your team's campaign lookup and update logic.
      // Keep failed or stale rows out of the mutation set.
    }
  });
}

function fetchVerifiedRows() {
  var response = UrlFetchApp.fetch(CONFIG.VERIFIED_ROWS_URL, {
    method: "get",
    headers: { "Authorization": "Bearer " + CONFIG.API_KEY },
    muteHttpExceptions: true
  });

  if (response.getResponseCode() >= 300) {
    throw new Error("Link Peeler state request failed: " + response.getContentText());
  }

  return JSON.parse(response.getContentText()).rows || [];
}
Implementation steps

Adapt the template without losing the safety model.

The skeleton is intentionally conservative. The mutation code belongs after verified-state checks, not before them.

01

Point at verified state

Use an endpoint that returns rows already resolved by Link Peeler.

02

Keep dry run active

Review logs for skipped, failed, and ready rows before enabling mutation.

03

Add campaign lookup

Map row campaign identifiers to the exact Google Ads entities your team owns.

04

Exclude unsafe rows

Never update campaigns from failed, skipped, unknown, or stale conclusions.

05

Audit after sync

Record which verified rows were consumed by the script.

Internal links

Related operating pages

Templates work best when they are connected to the guide, integration, and tool pages that explain the surrounding workflow.

R1

Google Ads final URL suffix guide

Understand how verified rows should feed suffix automation.

R2

Google Ads Scripts integration

See how campaign scripts consume verified Link Peeler state.

R3

Google Ads link risk calculator

Estimate risk before a template touches campaign operations.

Template FAQ

Questions about the Google Ads script template.

Can this script update campaigns immediately?

The template leaves mutation behind a DRY_RUN flag and a placeholder block. Add your own campaign lookup and update logic only after verified rows are logging correctly.

Why does it skip non-valid rows?

Campaign-facing scripts should not apply suffix changes from failed, skipped, stale, or unknown link state.

Where does the verified row endpoint come from?

Teams can expose verified state through Link Peeler workflows, Google Sheets result fields, or hosted platform API mode depending on the account setup.

Which page should I read next?

Read the Google Ads Scripts integration page and final URL suffix checklist before production updates.