DEV Community

Boehner
Boehner

Posted on

Check Your Landing Page Before Running Ads — A 60-Line Node.js Script

I watched a client spend $500 on Instagram ads driving to a page with no OG image, no clear CTA, and a 4-second load time. The ads weren't the problem — the page was. The ad creative was fine. The targeting was fine. But every click landed on a page that was invisible on social previews, had no obvious next step, and took forever to load on mobile.

So I wrote a 60-line script to catch this before the campaign launches.

What the script checks

The audit calls SnapAPI's /analyze and /metadata endpoints in parallel and checks eight things:

  • OG title — controls the headline shown when your link appears in an ad preview or is shared on social. Missing = your raw URL shows instead.
  • OG description — the subtitle below the headline in link previews. Missing = blank space.
  • OG image — the thumbnail. Missing = no image, lower click-through rate on every platform.
  • Twitter card — whether the page is set up for Twitter's expanded card format.
  • CTA count — detects visible call-to-action buttons. Zero CTAs on a landing page is a conversion leak.
  • Word count — pages with very little copy often lack context for cold visitors arriving from ads.
  • Tech stack — useful for diagnosing performance issues (is it a heavy SPA? tracking pixel bloat?).
  • Load time — pages slower than 3 seconds lose roughly half their mobile visitors before the page even finishes loading.

The core script logic

// Score each criterion
const s1 = ogTitle       ? 1 : 0;  // OG title present
const s2 = ogImage       ? 1 : 0;  // OG image present
const s3 = ctas.length   ? 1 : 0;  // At least 1 CTA
const s4 = wordCount > 300 ? 1 : 0; // Word count > 300
const s5 = loadTime  < 3000 ? 1 : 0; // Load time < 3s
const score = s1 + s2 + s3 + s4 + s5;

const recommendation =
  score <= 2 ? 'Needs significant work before running ads.' :
  score <= 4 ? 'Good — address the missing items above before launching.' :
               'Ad-ready. ✓';
Enter fullscreen mode Exit fullscreen mode

The full script runs both API calls in parallel with Promise.allSettled so a failure on one endpoint doesn't block the other, and prints a formatted report to stdout.

Sample output

────────────────────────────────────────────────
  PAGE AUDIT REPORT
────────────────────────────────────────────────
  URL:         https://example.com/ads/summer-sale
  OG Title:    Summer Sale — 40% Off Everything
  OG Desc:     Free shipping on orders over $50. Shop now.
  OG Image:    ✗ MISSING
  Twitter Card: (not set)
  CTAs found:  2 — Shop Now, Add to Cart
  Word Count:  487 ✓
  Tech Stack:  Shopify, Google Analytics, Facebook Pixel
  Load Time:   2341ms ✓
────────────────────────────────────────────────
  Score: 3/5
  → Good — address the missing items above before launching.
────────────────────────────────────────────────
Enter fullscreen mode Exit fullscreen mode

The missing OG image is the fix here — that's a 15-minute Canva job that will meaningfully improve CTR on every platform.

How to use it

No npm install. Node.js 18+ only.

git clone https://github.com/Boehner/page-audit
cd page-audit
export SNAPAPI_KEY=your_key_here
node page-audit.js https://your-landing-page.com
Enter fullscreen mode Exit fullscreen mode

The free SnapAPI tier is 100 checks/month — enough to audit every page in your funnel weekly without paying anything.

Taking it further

  • Run pre-deploy in CI — add node page-audit.js https://yoursite.com/lp as a step in your deploy workflow. If score drops below 4, fail the deploy.
  • Audit competitor landing pages — before copying a competitor's strategy, run their pages through the audit. You might find they're running ads to a page with a 4-second load time too.
  • Batch check your whole funnel — use the SnapAPI batch endpoint to audit 10+ pages in a single API call. Useful before a major campaign launch.

Free API key

SnapAPI gives you 100 free checks/month — no credit card, key active in 30 seconds.

snapapi.tech

Top comments (0)