PERFORMANCE STUDIOFree growth audit
ServicesToolsError HubGrowth LabCase StudiesInsightsIndustriesMarketsReviewsAboutContact
AD SCRIPT LIBRARY / OPEN ACCESS

Copy useful advertising scripts without giving us your email.

Every script includes a safety note and is designed as a reviewable starting point. Preview changes, validate platform documentation and keep credentials outside source code.

Open the Ad Waste Calculator ↗Troubleshoot an error code ↗
01 / GOOGLE ADS SCRIPTS

Pause high-spend keywords with zero conversions

Find enabled keywords above a defined cost threshold with zero primary conversions during the selected period, then pause them and write an audit log.

function main() {
  const SPEND_LIMIT = 5000; // account currency
  const DATE_RANGE = 'LAST_30_DAYS';
  const keywords = AdsApp.keywords()
    .withCondition('Status = ENABLED')
    .withCondition('Cost > ' + SPEND_LIMIT)
    .withCondition('Conversions = 0')
    .forDateRange(DATE_RANGE)
    .get();

  while (keywords.hasNext()) {
    const keyword = keywords.next();
    Logger.log(JSON.stringify({
      action: 'pause',
      campaign: keyword.getCampaign().getName(),
      adGroup: keyword.getAdGroup().getName(),
      keyword: keyword.getText(),
      cost: keyword.getStatsFor(DATE_RANGE).getCost()
    }));
    keyword.pause();
  }
}

SAFE USE: Run in Preview first. A zero-conversion keyword can still assist sales, so review search terms, conversion setup and business value before allowing automatic pauses.

03 / META PIXEL + CONVERSIONS API

Check browser and server event deduplication hourly

Compare your own browser and server event log by event name and event ID. This avoids pretending Meta exposes raw user events through a public diagnostics endpoint.

const HOUR_MS = 60 * 60 * 1000;

function auditDeduplication(events) {
  const recent = events.filter(event => Date.now() - event.timestamp <= HOUR_MS);
  const pairs = new Map();

  for (const event of recent) {
    const key = event.eventName + ':' + event.eventId;
    const pair = pairs.get(key) || new Set();
    pair.add(event.source); // 'browser' or 'server'
    pairs.set(key, pair);
  }

  const complete = [...pairs.values()].filter(sources =>
    sources.has('browser') && sources.has('server')
  ).length;
  const rate = pairs.size ? (complete / pairs.size) * 100 : 0;

  return {
    checkedEvents: pairs.size,
    matchedPairs: complete,
    deduplicationRate: Number(rate.toFixed(1)),
    status: rate >= 90 ? 'healthy' : 'review event_name and event_id'
  };
}

// Schedule this against your consented event log every hour.
console.log(auditDeduplication(eventLog));

SAFE USE: Pass only consented, non-sensitive event metadata into the monitor. Never log access tokens, raw email, phone numbers or customer payloads.

04 / JAVASCRIPT / ANALYTICS

Audit landing-page UTM consistency

Detect missing campaign parameters and inconsistent casing before traffic-source reports fragment.

const required = ['utm_source', 'utm_medium', 'utm_campaign'];

function auditUtm(urls) {
  return urls.map(rawUrl => {
    const url = new URL(rawUrl);
    const missing = required.filter(key => !url.searchParams.get(key));
    const uppercase = required.filter(key => /[A-Z]/.test(url.searchParams.get(key) || ''));
    return { url: rawUrl, missing, uppercase, valid: !missing.length && !uppercase.length };
  });
}

console.table(auditUtm([
  'https://example.com/?utm_source=google&utm_medium=cpc&utm_campaign=brand_india'
]));

SAFE USE: Run on your staging or QA URL set. Do not append tracking values that expose customer or private account data.

05 / JAVASCRIPT / CRM

Score lead quality without storing personal data

Create a transparent score from location, service relevance, intent and contactability so campaign feedback is more useful than raw lead count.

function scoreLead({ locationFit, serviceFit, intent, reachable }) {
  const weights = { locationFit: 25, serviceFit: 35, intent: 25, reachable: 15 };
  const score =
    (locationFit ? weights.locationFit : 0) +
    (serviceFit ? weights.serviceFit : 0) +
    (intent === 'high' ? weights.intent : intent === 'medium' ? 12 : 0) +
    (reachable ? weights.reachable : 0);

  return {
    score,
    band: score >= 75 ? 'qualified' : score >= 45 ? 'review' : 'low-fit'
  };
}

console.log(scoreLead({
  locationFit: true,
  serviceFit: true,
  intent: 'high',
  reachable: true
}));

SAFE USE: Use the score to prioritise review, not to make sensitive or discriminatory decisions. Keep the rules visible to the sales team.

WhatsApp us