Skip to content

SandiRidwan/ttm-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Sandi Ridwan Roles

🔍 TTM Scanner — TrackToMeasure

Behavioral + Network-Based Tracking Tag Detection Engine

Node.js Playwright Express License Accuracy


╔══════════════════════════════════════════════════════════╗
║  SCAN RESULTS — shopify.com                              ║
╠══════════════════════════════════════════════════════════╣
║  🟢  Google Tag Manager    DETECTED  [GTM-TZ26LP8]       ║
║  🟢  Google Analytics 4   DETECTED  [G-W6NECZNE63]      ║
║  🟢  Meta Pixel            DETECTED  [1298671233649970]   ║
║  🟡  Google Ads            DETECTED  [via Doubleclick]    ║
║  🟢  LinkedIn Insight      DETECTED  [8308876]            ║
║──────────────────────────────────────────────────────────║
║  Tags found: 5 / 9  |  Scan time: 14.5s  |  Acc: 100%  ║
╚══════════════════════════════════════════════════════════╝

⚡ What Is This?

TTM Scanner is a production-grade tracking tag detection engine built for the TrackToMeasure SaaS platform. It upgrades basic static HTML scanning (50% accuracy) to a 5-layer behavioral + network detection system achieving 90–95%+ accuracy across modern websites.

Unlike static scanners that only read HTML, TTM Scanner:

  • Intercepts network requests before they fire
  • Bypasses consent walls (OneTrust, Shopify, Wix, GDPR) automatically
  • Triggers lazy-loaded tags via smart scroll simulation
  • Reads runtime window objects to extract tag IDs that never appear in HTML
  • Wraps everything in a clean REST API + Admin Panel

🎯 Supported Tags (9 Total)

Tag ID Format Example
🏷️ Google Tag Manager GTM-XXXXXX GTM-TZ26LP8
📊 Google Analytics 4 G-XXXXXXXXX G-W6NECZNE63
👁️ Meta Pixel Numeric (10–15 digits) 1298671233649970
💰 Google Ads AW-XXXXXXXXX AW-990123219
🎵 TikTok Pixel CXXXXXXXXX... CABCDE123456789
💼 LinkedIn Insight Tag Numeric 8308876
🔥 Hotjar Numeric 35118
🔵 Microsoft Clarity Alphanumeric abcde12345
💬 Intercom Alphanumeric xyz12345

🧠 Detection Architecture

                    ┌─────────────────────────────┐
                    │        TARGET WEBSITE        │
                    └──────────────┬──────────────┘
                                   │
          ┌────────────────────────▼────────────────────────┐
          │              LAYER 1: CONSENT BYPASS             │
          │  Inject OneTrust / Shopify / Wix / GDPR cookies  │
          │              before page loads                    │
          └────────────────────────┬────────────────────────┘
                                   │
          ┌────────────────────────▼────────────────────────┐
          │           LAYER 2: NETWORK INTERCEPT             │
          │   page.on('request') → match URL patterns        │
          │   facebook.com/tr, googletagmanager.com, etc.    │
          └────────────────────────┬────────────────────────┘
                                   │
          ┌────────────────────────▼────────────────────────┐
          │           LAYER 3: BEHAVIORAL SCROLL             │
          │   3-pass smart scroll → triggers lazy tags       │
          │   waitUntil: 'load' + 2.5s → 57% faster         │
          └────────────────────────┬────────────────────────┘
                                   │
          ┌────────────────────────▼────────────────────────┐
          │         LAYER 4: WINDOW OBJECT DETECTION         │
          │   window.fbq / window.gtag / google_tag_manager  │
          │   + runtime ID extraction via page.evaluate()    │
          └────────────────────────┬────────────────────────┘
                                   │
          ┌────────────────────────▼────────────────────────┐
          │           LAYER 5: HTML PATTERN MATCH            │
          │   Regex scan of fully-rendered page source       │
          └────────────────────────┬────────────────────────┘
                                   │
                    ┌──────────────▼──────────────┐
                    │     STRUCTURED JSON OUTPUT   │
                    │  tag + id + confidence + ms  │
                    └─────────────────────────────┘

📊 Accuracy Test Results

Tested on real production websites — no mocking, no local servers.

Website Platform Tags Found Accuracy Scan Time
shopify.com Shopify 5 tags 100% 14.5s
hubspot.com HubSpot 7 tags 100% 14.9s
webflow.com Webflow 5 tags 100% 19.8s
Overall 🟢 100% ~16s avg

🚀 Quick Start

# 1. Clone
git clone https://github.com/sandiridwan/ttm-scanner.git
cd ttm-scanner

# 2. Install
npm install
npx playwright install chromium

# 3. Scan a website (CLI)
node scan.js https://example.com

# 4. Start API server
node src/api.js
# → http://localhost:3000/health
# → http://localhost:3000/admin

🔌 API Reference

Scan a single URL

curl -X POST http://localhost:3000/scan \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com"}'

Batch scan (up to 5 URLs)

curl -X POST http://localhost:3000/scan/batch \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://a.com", "https://b.com"]}'

Sample Response

{
  "url": "https://shopify.com",
  "scannedAt": "2026-04-24T04:54:54.800Z",
  "durationMs": 14511,
  "tags": {
    "gtm": {
      "name": "Google Tag Manager",
      "detected": true,
      "id": "GTM-TZ26LP8",
      "detectionMethod": "network + window + html",
      "confidence": "high"
    },
    "meta_pixel": {
      "name": "Meta Pixel (Facebook)",
      "detected": true,
      "id": "1298671233649970",
      "detectionMethod": "network + window + html",
      "confidence": "high"
    }
  },
  "summary": [...],
  "errors": []
}

🖥️ Admin Panel

Access at http://localhost:3000/admin

Feature Detail
📝 Post Management Create, edit, delete blog/event posts
🖼️ Image Upload Drag & drop, JPG/PNG/GIF/WebP, max 5MB
🔍 SEO Fields Title, description, keywords + live Google preview
📊 Status Control Draft / Published with one click
🔎 Built-in Scanner Scan any URL directly from admin panel

🐳 Docker

docker build -t ttm-scanner .
docker run -d -p 3000:3000 \
  -v $(pwd)/data:/app/data \
  -v $(pwd)/uploads:/app/uploads \
  ttm-scanner

🗂️ Project Structure

ttm-scanner/
├── src/
│   ├── scanner.js          # 5-layer detection engine
│   ├── api.js              # Express REST API
│   └── admin/
│       ├── routes.js       # CRUD API routes
│       └── panel.html      # Admin panel UI
├── test-sites/             # Local test pages (9 tags)
├── scan.js                 # CLI runner
├── test-multi-site.js      # Multi-site accuracy test
├── Dockerfile
└── INTEGRATION.md          # Integration guide for existing codebases

🧪 Run Accuracy Tests

# Quick test (3 sites)
node test-multi-site.js --quick

# Full test (10 sites)
node test-multi-site.js

🛠️ Add New Tags

Edit TAG_SIGNATURES in src/scanner.js:

your_tag: {
  name: 'Your Tag Name',
  network: [ /url-pattern\.com\/path/ ],
  windowObjects: ['windowVarName'],
  htmlPatterns: [ /html-regex-pattern/ ],
  idExtract: {
    network: /extract-group-(\w+)/,
    html: /extract-group-(\w+)/,
  },
},

🔗 Confidence Levels

Icon Level Meaning
🟢 high Detected by 3+ layers
🟡 medium Detected by 2 layers or network alone
🟠 low HTML pattern only — present but not firing
🔴 none Not detected

Built by Sandi Ridwan Data Automation Engineer · Web Scraping Specialist · Palu, Indonesia

LinkedIn GitHub Email

About

Behavioral + network-based tracking tag detection engine. 9 tags, 5-layer detection, 100% accuracy. Node.js + Playwright + REST API + Admin Panel.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors