Skip to content

nightfairy5831/ad_saas

Repository files navigation

Landing Page Personalization SaaS

Real-time landing page personalization based on ad campaign data. Automatically adapt your landing page content to match the ad that brought each visitor, increasing conversion rates through message consistency.

πŸš€ What It Does

This SaaS personalizes landing pages in real-time based on the ad a visitor clicked (UTM tags, ad IDs, etc.). Customers paste one line of JavaScript code into their funnel builder (ClickFunnels, Webflow, WordPress, Shopify, etc.), and the system automatically:

  • Reads ad/UTM parameters from the URL
  • Matches visitors to audience segments
  • Swaps landing page text (headlines, subheadlines, bullets, CTAs) to match the ad promise
  • Tracks performance vs. a control group

Think: "Google Optimize + Copy.ai" but simplified for ad-driven funnels.

πŸ“‹ Core Features

MVP Features

βœ… One-Line JavaScript Snippet - Easy integration with any website
βœ… UTM-Based Segmentation - Automatic visitor segmentation based on campaign parameters
βœ… Dynamic Content Swapping - Real-time replacement of headlines, subheadlines, bullets, and CTAs
βœ… A/B Testing - Built-in 5-10% holdout group for performance measurement
βœ… Multi-Tenant Architecture - Separate workspaces for each customer
βœ… Event Tracking - Page views, clicks, conversions with revenue attribution
βœ… Dashboard - Manage segments, variants, and view analytics
βœ… Stripe Billing - Subscription management with trial support

Coming Soon

πŸ”„ AI Copy Generation - Auto-generate variant copy with GPT-4
πŸ”„ Ad Platform Integration - Direct sync with Meta/Google Ads
πŸ”„ WordPress/Shopify Plugins - Native integrations

πŸ›  Tech Stack

  • Frontend: Next.js 14 (App Router), React 18, TypeScript, Tailwind CSS
  • Backend: Next.js API Routes
  • Database: PostgreSQL (Supabase)
  • ORM: Prisma
  • Cache: Redis (Upstash/Vercel KV)
  • Auth: Supabase Auth
  • Payments: Stripe
  • Hosting: Vercel
  • AI: OpenAI GPT-4 (optional)

πŸ— Project Structure

ad_SasS/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (auth)/           # Auth pages (login, signup)
β”‚   β”‚   β”œβ”€β”€ (dashboard)/      # Dashboard (protected)
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/    # Overview & stats
β”‚   β”‚   β”‚   β”œβ”€β”€ segments/     # Segment management
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics/    # Performance tracking
β”‚   β”‚   β”‚   └── subscription/ # Billing
β”‚   β”‚   └── api/
β”‚   β”‚       β”œβ”€β”€ v1/
β”‚   β”‚       β”‚   β”œβ”€β”€ content/  # Content API
β”‚   β”‚       β”‚   β”œβ”€β”€ events/   # Event tracking
β”‚   β”‚       β”‚   └── snippet/  # JS snippet
β”‚   β”‚       └── stripe/       # Webhooks
β”‚   β”œβ”€β”€ components/           # Reusable components
β”‚   β”œβ”€β”€ lib/                  # Utilities
β”‚   └── types/               # TypeScript types
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma        # Database schema
└── public/
    └── snippet.js           # JavaScript snippet

πŸ“¦ Installation

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Supabase account
  • Stripe account
  • Redis instance (optional for caching)

Quick Start

  1. Clone & Install
git clone <repository-url>
cd ad_SasS
npm install
  1. Environment Setup
cp .env.example .env

Update .env with your credentials:

# Database
DATABASE_URL="postgresql://..."
DIRECT_URL="postgresql://..."

# Supabase
NEXT_PUBLIC_SUPABASE_URL="https://..."
NEXT_PUBLIC_SUPABASE_ANON_KEY="..."
SUPABASE_SERVICE_ROLE_KEY="..."

# Redis (optional)
REDIS_URL="redis://..."

# Stripe
STRIPE_SECRET_KEY="sk_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_..."

# OpenAI (optional)
OPENAI_API_KEY="sk-..."
  1. Database Setup
npx prisma migrate dev
npx prisma generate
npx prisma db seed # Optional: seed sample data
  1. Run Development Server
npm run dev

Visit http://localhost:3000

πŸ“Š How It Works

1. Customer Integration Flow

Customer signs up β†’ Gets API key β†’ Installs snippet on site

2. Visitor Personalization Flow

Visitor clicks ad β†’ Lands on page β†’ Snippet reads UTMs β†’ 
Fetches personalized content β†’ Swaps page elements β†’ Tracks events

3. JavaScript Snippet Example

<script>
  (function(w,d,s,id){
    var js,fjs=d.getElementsByTagName(s)[0];
    if(d.getElementById(id))return;
    js=d.createElement(s);js.id=id;
    js.src='https://yourdomain.com/snippet.js';
    js.setAttribute('data-api-key','YOUR_API_KEY');
    fjs.parentNode.insertBefore(js,fjs);
  }(window,document,'script','lp-personalize'));
</script>

πŸ”‘ Database Models

Core Models

  • Tenant - Customer workspace with API key
  • User - Team members with role-based access
  • Segment - Audience segments with UTM rules
  • SegmentVariant - Content variations per segment
  • Event - Visitor tracking (views, clicks, conversions)
  • Subscription - Stripe billing integration

πŸ“‘ API Endpoints

Content API

POST /api/v1/content
{
  "apiKey": "tenant-api-key",
  "utm_source": "facebook",
  "utm_campaign": "summer-sale",
  "visitorId": "cookie-id"
}

Response:
{
  "segment": "social-shoppers",
  "content": {
    "headline": "Summer Sale - 50% Off!",
    "subheadline": "The deal Facebook users love",
    "bullets": ["Free shipping", "30-day returns"],
    "ctaText": "Shop Now"
  }
}

Event Tracking

POST /api/v1/events
{
  "apiKey": "tenant-api-key",
  "type": "CONVERSION",
  "visitorId": "cookie-id",
  "revenue": 99.99,
  "metadata": {...}
}

πŸ“ˆ Performance

  • Response Time: <50ms (cached)
  • Snippet Size: <5KB gzipped
  • Zero Layout Shift: Content swapped before paint
  • Privacy-First: No PII collected

🚦 Development Scripts

npm run dev           # Start dev server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # TypeScript check
npm run test         # Run tests

# Prisma
npm run prisma:generate  # Generate client
npm run prisma:migrate   # Run migrations
npm run prisma:studio    # Open Prisma Studio
npm run prisma:seed      # Seed database

πŸš€ Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Import to Vercel
  3. Add environment variables
  4. Deploy

Manual Deployment

npm run build
npm run start

πŸ“ Success Metrics

  • βœ… Customer can paste snippet and see dynamic text swap
  • βœ… Segment rules apply correctly based on UTMs
  • βœ… Events tracked and visible in dashboard
  • βœ… Stripe billing functional
  • βœ… <50ms API response time with caching

πŸ—Ί Roadmap

Week 1 βœ…

  • Project setup & database schema
  • Content API with Redis cache
  • Rules engine for UTM matching
  • Event tracking endpoint

Week 2 (Current)

  • JavaScript snippet implementation
  • Dashboard skeleton with auth
  • Segment CRUD operations
  • Per-tenant API keys

Week 3

  • Variant management UI
  • Analytics charts & reporting
  • Stripe integration
  • A/B testing with holdout

Week 4

  • Polish & bug fixes
  • Deployment to production
  • Beta user onboarding
  • Documentation

πŸ“ License

Proprietary - All Rights Reserved

🀝 Support

For questions or issues, contact: support@yourdomain.com

About

Landing Page Personalization Platform for Higher Conversions, Increased Revenue, and Better ROI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors