AI-powered paywall and subscription conversion system
Media and SaaS freemium models convert 2-5% of users to subscriptions. AI-optimizing the paywall — showing the right CTA to the right user at the right moment — increases this to 4-9%.
Subscription purchase intent model
import numpy as np
import pandas as pd
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.calibration import CalibratedClassifierCV
class PaywallConversionPredictor:
"""Predict subscription conversion probability"""
def __init__(self):
base = GradientBoostingClassifier(
n_estimators=200, learning_rate=0.05, max_depth=4, random_state=42
)
self.model = CalibratedClassifierCV(base, method='isotonic', cv=5)
def build_features(self, user_sessions: pd.DataFrame) -> pd.DataFrame:
"""Behavioral features predicting conversion"""
return pd.DataFrame({
# Engagement depth
'articles_read_30d': user_sessions['articles_read_30d'],
'paywall_hits_7d': user_sessions['paywall_hits_7d'], # Key signal
'search_queries_7d': user_sessions['search_queries_7d'],
'days_active_30d': user_sessions['days_active_30d'],
'bookmarks_count': user_sessions['bookmarks_count'],
# Reading depth
'avg_read_completion': user_sessions['avg_read_completion'], # 0-1
'premium_content_attempts': user_sessions['premium_content_attempts'],
# Technical
'email_verified': user_sessions['email_verified'].astype(int),
'newsletter_subscriber': user_sessions['newsletter_subscriber'].astype(int),
'mobile_app_installed': user_sessions.get('has_app', pd.Series([0])).astype(int),
# Source and channel
'organic_traffic': user_sessions.get('organic_ratio', 0.5),
'days_since_registration': user_sessions['days_since_registration'].clip(0, 365),
# Contextual
'current_session_paywall_hit': user_sessions['current_session_paywall_hit'].astype(int),
'referral_from_premium': user_sessions.get('from_premium_referral', 0).astype(int),
}).fillna(0)
def predict(self, users: pd.DataFrame) -> pd.DataFrame:
X = self.build_features(users)
probs = self.model.predict_proba(X)[:, 1]
result = users[['user_id']].copy() if 'user_id' in users.columns else pd.DataFrame(index=users.index)
result['conversion_probability'] = probs
result['segment'] = pd.cut(probs, bins=[0, 0.15, 0.40, 0.70, 1.0],
labels=['unlikely', 'potential', 'likely', 'hot'])
return result
class DynamicPaywallStrategy:
"""Dynamic paywall strategy"""
# Strategies by segment
STRATEGIES = {
'hot': {
'paywall_type': 'hard',
'free_articles_remaining': 0,
'offer': 'annual_plan_30_off',
'urgency': True,
'message': 'You read us actively — save 30% on annual plan'
},
'likely': {
'paywall_type': 'metered',
'free_articles_remaining': 2,
'offer': 'monthly_first_month_free',
'urgency': False,
'message': 'First month free'
},
'potential': {
'paywall_type': 'soft',
'free_articles_remaining': 5,
'offer': 'newsletter_upsell',
'urgency': False,
'message': 'Subscribe to our best content newsletter'
},
'unlikely': {
'paywall_type': 'none',
'free_articles_remaining': 10,
'offer': None,
'urgency': False,
'message': ''
}
}
def get_strategy(self, user_segment: str,
context: dict) -> dict:
"""Strategy for user with context"""
strategy = dict(self.STRATEGIES.get(user_segment, self.STRATEGIES['unlikely']))
# Contextual modifications
if context.get('is_breaking_news') and user_segment in ['hot', 'likely']:
strategy['paywall_type'] = 'hard'
strategy['message'] = f"Exclusive: {context.get('article_title', 'This article')} for subscribers only"
if context.get('is_mobile') and strategy['offer']:
strategy['offer'] = strategy['offer'] + '_mobile_checkout'
if context.get('hour') in range(20, 24) and user_segment == 'hot':
strategy['urgency_message'] = 'Offer expires end of day'
return strategy
def select_offer(self, user: dict,
available_offers: list[dict]) -> dict:
"""A/B test offers: select variant for user"""
# Deterministic variant assignment
bucket = hash(user['user_id']) % 100
offer_idx = min(bucket // (100 // len(available_offers)), len(available_offers) - 1)
return available_offers[offer_idx]
class ChurnPreventionForSubscribers:
"""Retain subscribers before cancellation"""
def predict_cancellation_risk(self, subscription_data: pd.DataFrame) -> pd.DataFrame:
"""Predict subscription cancellation risk before renewal"""
df = subscription_data.copy()
# Risk indicators
df['risk_score'] = (
(df['logins_last_month'] < 2).astype(float) * 0.30 +
(df['days_since_last_read'] > 14).astype(float) * 0.25 +
(df['opened_cancel_page']).astype(float) * 0.35 +
(df['support_cancel_inquiry']).astype(float) * 0.10
)
df['churn_risk'] = pd.cut(
df['risk_score'],
bins=[0, 0.3, 0.6, 1.0],
labels=['low', 'medium', 'high']
)
return df
def generate_retention_offer(self, subscriber: dict) -> dict:
"""Personalized offer for retention"""
months_subscribed = subscriber.get('months_subscribed', 1)
plan = subscriber.get('plan', 'monthly')
if months_subscribed > 12:
return {
'type': 'loyalty_discount',
'discount_pct': 25,
'message': f'You've been with us {months_subscribed} months — get 25% off next year'
}
elif plan == 'monthly':
return {
'type': 'plan_upgrade_offer',
'offer': 'annual_plan_with_savings',
'message': 'Switch to annual plan and save 40%'
}
else:
return {
'type': 'pause_option',
'pause_weeks': 4,
'message': 'No time to read? Pause subscription for 4 weeks'
}
Proper paywall segmentation (different strategies for different conversion probabilities) increases subscription revenue by 20-35% without changing rates. Key insight: too strict paywall for low-intent users increases bounce; too soft for high-intent leaves money on the table.







