Cursor Rules Template: Marketing Analytics Platform with Campaign Tracking, Attribution, Landing Page Analytics and AI Insights
Cursor Rules Template for building a marketing analytics platform with campaign tracking, attribution, landing page analytics, and AI insights on a Node.js/Express stack with PostgreSQL and Redis.
Target User
Developers building marketing analytics platforms
Use Cases
- Campaign tracking integration
- Attribution modeling
- Landing page analytics instrumentation
- AI-powered insights in dashboards
- Data integrity and privacy controls
Markdown Template
Cursor Rules Template: Marketing Analytics Platform with Campaign Tracking, Attribution, Landing Page Analytics and AI Insights
// Cursor Rules Template: Marketing Analytics Stack (Node.js + Express + PostgreSQL + Redis)
// Framework Role & Context
Framework: Node.js + Express (TypeScript) + PostgreSQL + Redis
Role: Backend + Data Platform engineer
Context: You are configuring Cursor rules for a marketing analytics platform with campaign tracking, attribution, landing page analytics, and AI insights
// Code Style and Style Guides
Language: TypeScript
Lint: ESLint + Prettier
Strict: true
Documentation: JSDoc
// Architecture & Directory Rules
Project layout
src/server/controllers
src/server/routes
src/server/middleware
src/server/services
src/server/models
src/server/config
src/server/db
src/server/migrations
src/client/components
src/client/pages
src/client/hooks
src/common/types
// Authentication & Security Rules
Auth: JWT tokens, HttpOnly cookies, short-lived access tokens, refresh tokens
Secrets: load from env, no secrets in code
// Database and ORM patterns
Db: PostgreSQL
Queries: parameterized
ORM: repository pattern
Migrations: managed with migration tools
// Testing & Linting Workflows
Tests: jest
CI: npm run test
// Prohibited Actions and Anti-patterns
No dynamic SQL without parameters
No hardcoded secrets
No code that leaks user data
No bypass validationsOverview
Cursor rules configuration for Cursor AI editor helps you define a safe, repeatable set of rules for building a marketing analytics platform. This Cursor rules template targets a Node.js/Express stack with PostgreSQL and Redis, and covers campaign tracking, attribution, landing page analytics, and AI insights.
Direct answer: This Cursor rules template provides a complete, copyable .cursorrules block and stack-specific guidance to implement campaign tracking, attribution models, landing page analytics, and AI-assisted insights in a production-ready Node.js environment with Cursor AI.
When to Use These Cursor Rules
- You are building a marketing analytics platform requiring campaign tracking across channels.
- You need deterministic attribution modeling and end-to-end data lineage.
- You instrument landing page analytics and cohort analysis for AI-driven insights.
- You want a repeatable, opinionated project structure with enforced coding and security practices.
Copyable .cursorrules Configuration
// Cursor Rules Template: Marketing Analytics Stack (Node.js + Express + PostgreSQL + Redis)
// Framework Role & Context
Framework: Node.js + Express (TypeScript) + PostgreSQL + Redis
Role: Backend + Data Platform engineer
Context: You are configuring Cursor rules for a marketing analytics platform with campaign tracking, attribution, landing page analytics, and AI insights
// Code Style and Style Guides
Language: TypeScript
Lint: ESLint + Prettier
Strict: true
Documentation: JSDoc
// Architecture & Directory Rules
Project layout
src/server/controllers
src/server/routes
src/server/middleware
src/server/services
src/server/models
src/server/config
src/server/db
src/server/migrations
src/client/components
src/client/pages
src/client/hooks
src/common/types
// Authentication & Security Rules
Auth: JWT tokens, HttpOnly cookies, short-lived access tokens, refresh tokens
Secrets: load from env, no secrets in code
// Database and ORM patterns
Db: PostgreSQL
Queries: parameterized
ORM: repository pattern
Migrations: managed with migration tools
// Testing & Linting Workflows
Tests: jest
CI: npm run test
// Prohibited Actions and Anti-patterns
No dynamic SQL without parameters
No hardcoded secrets
No code that leaks user data
No bypass validations
Recommended Project Structure
project-root/
package.json
tsconfig.json
src/
server/
controllers/
routes/
middleware/
services/
models/
config/
db/
migrations/
client/
src/
components/
pages/
hooks/
tests/
migrations/
.env
Core Engineering Principles
- Strong typing and explicit interfaces in TypeScript
- Clear separation of concerns between server, client, and data layer
- Security by default: validation, least privilege DB access, encrypted secrets
- Observability: structured logging and metrics
- Deterministic data access patterns and idempotent operations
Code Construction Rules
- Use TypeScript with strict mode; define DTOs for API surfaces
- Parameterize all SQL queries; avoid string concatenation
- Repository pattern for data access; services orchestrate business logic
- Environment-based configuration; avoid hard-coded values
- Document complex logic with JSDoc; enable analyzers
- Cursor AI usage: provide context, avoid unsafe operations, verify results, log decisions
Security and Production Rules
- TLS termination in front-door; secrets in environment variables
- Use JWTs with short lifetimes; refresh tokens rotated securely
- Validate and sanitize all inputs; rate limit endpoints; CSRF protection for state-changing calls
- DB: least privilege user; parameterized queries; auditing enabled
Testing Checklist
- Unit tests for repositories and utilities
- Integration tests for API endpoints and data flows
- End-to-end tests for key user journeys in the analytics dashboards
- CI pipeline runs lint, tests, and type checks on PRs
Common Mistakes to Avoid
- Ignoring data privacy and over-fetching analytics data
- Using dynamic SQL without parameters; leaking secrets in code
- Skipping input validation and error handling for analytics endpoints
- Over-optimizing without measuring performance impact
Related Cursor rules templates
Explore adjacent Cursor rules templates for similar stacks, workflows, and production constraints.
- Cursor Rules Template: Client Onboarding Portal with Forms, Uploads, E-Sign and Admin Dashboards
- Field Sales Cursor Rules Template: Location Check-ins, Visits, Notes, Tasks, and Manager Analytics
- Cursor Rules Template: SaaS Revenue Dashboard (MRR, ARR, Churn & Cohorts)
- Cursor Rules Template: Node Express PostgreSQL Community Platform
FAQ
What is included in this Cursor Rules Template for marketing analytics?
This Cursor Rules Template includes a copyable .cursorrules block tailored to a Node.js/Express + PostgreSQL + Redis stack, plus stack-specific guidance for campaign tracking, attribution, landing page analytics, and AI insights.
How do I enable AI insights while keeping data secure?
Where should I place the .cursorrules file?
Place the .cursorrules file at the project root of the analytics service, so Cursor AI can load it during code generation and validation steps.
Can I adapt this to a different stack?
You can adapt the structure by changing the framework and db layer references, but keep the same patterns for security, testing, and clean architecture.
What tests are recommended for analytics pipelines?
Unit tests for data access, integration tests for endpoints, and end-to-end tests for dashboards, wired into CI with linting and type checks.