Create an Affiliate Program with Memberstack
Step-by-step guide to integrating affiliate tracking with your Memberstack membership platform
Memberstack is a powerful membership platform that integrates seamlessly with Webflow, Framer, and custom websites. If you're using Memberstack to manage memberships and want to grow through affiliate marketing, AffiliateBase provides seamless integration.
This comprehensive guide will walk you through everything you need to know about setting up an affiliate program with Memberstack, from webhook configuration to tracking membership sign-ups, subscription purchases, and member upgrades.
Whether you're running a paid community, offering tiered memberships, or selling access to exclusive content, an affiliate program can help you acquire new members while rewarding your partners for successful referrals.
Follow these steps to integrate AffiliateBase with Memberstack:
Set Up Memberstack Webhooks
https://api.affiliatebase.com/webhooks/memberstack
Select Webhook Events
Add Webhook Secret to AffiliateBase
Configure Commission Rules
Pass Affiliate IDs to Memberstack
Test the Integration
Memberstack Webhook Handler Example
Here's an example of how to handle Memberstack webhooks for affiliate tracking:
// Example: Next.js API route for Memberstack webhooks
import { headers } from 'next/headers';
import crypto from 'crypto';
import { AffiliateBase } from '@affiliatebase/sdk';
const affiliateBase = new AffiliateBase({
apiKey: process.env.AFFILIATEBASE_API_KEY!,
});
export async function POST(request: Request) {
const body = await request.text();
const signature = headers().get('x-memberstack-signature')!;
// Verify webhook signature
const expectedSignature = crypto
.createHmac('sha256', process.env.MEMBERSTACK_WEBHOOK_SECRET!)
.update(body)
.digest('hex');
if (signature !== expectedSignature) {
return new Response('Invalid signature', { status: 401 });
}
const event = JSON.parse(body);
// Handle different event types
switch (event.type) {
case 'member.created':
// Only track if member has a paid subscription
if (event.data.member.subscription_id) {
await affiliateBase.trackConversion({
affiliateId: event.data.member.metadata?.affiliateId,
type: 'membership_signup',
amount: event.data.member.subscription?.price,
currency: event.data.member.subscription?.currency,
customerId: event.data.member.id,
subscriptionId: event.data.member.subscription_id,
metadata: {
plan_id: event.data.member.plan_id,
plan_name: event.data.member.plan_name,
},
});
}
break;
case 'subscription.created':
await affiliateBase.trackConversion({
affiliateId: event.data.subscription.metadata?.affiliateId,
type: 'subscription',
amount: event.data.subscription.price,
currency: event.data.subscription.currency,
customerId: event.data.subscription.member_id,
subscriptionId: event.data.subscription.id,
metadata: {
plan_id: event.data.subscription.plan_id,
plan_name: event.data.subscription.plan_name,
},
});
break;
case 'payment.succeeded':
await affiliateBase.trackConversion({
affiliateId: event.data.payment.metadata?.affiliateId,
type: 'payment',
amount: event.data.payment.amount,
currency: event.data.payment.currency,
customerId: event.data.payment.member_id,
metadata: {
payment_id: event.data.payment.id,
subscription_id: event.data.payment.subscription_id,
},
});
break;
case 'subscription.updated':
// Track subscription upgrades/downgrades
if (event.data.subscription.previous_price !== event.data.subscription.price) {
await affiliateBase.trackConversion({
affiliateId: event.data.subscription.metadata?.affiliateId,
type: 'subscription_upgrade',
amount: event.data.subscription.price - event.data.subscription.previous_price,
currency: event.data.subscription.currency,
customerId: event.data.subscription.member_id,
subscriptionId: event.data.subscription.id,
});
}
break;
}
return new Response(JSON.stringify({ received: true }), { status: 200 });
}
Why Use AffiliateBase with Memberstack?
AffiliateBase is the perfect solution for Memberstack users who want powerful affiliate tracking without complexity.
Native Memberstack Integration
Built-in integration with Memberstack webhooks. Automatically tracks membership sign-ups, subscriptions, and upgrades without custom code.
Works with Webflow & Framer
Perfect for Memberstack users building membership sites on Webflow or Framer. Track conversions seamlessly across your no-code stack.
Subscription Lifecycle Tracking
Tracks subscription renewals, upgrades, downgrades, and cancellations. Ensures affiliates receive commissions for recurring revenue.
Multiple Membership Tiers
Support for different commission rates based on membership tier or plan. Perfect for sites with multiple membership levels.
Real-Time Tracking
Track conversions in real-time as members join or upgrade. No delays or batch processing.
Affiliate Dashboard
Give your affiliates a professional dashboard to track their performance, view commissions, and generate affiliate links for your membership site.
Frequently Asked Questions
Does AffiliateBase work with Memberstack? ▼
Yes! AffiliateBase integrates seamlessly with Memberstack through webhooks. It automatically tracks membership sign-ups, subscription purchases, and membership upgrades.
How are membership sign-ups tracked? ▼
AffiliateBase tracks Memberstack memberships through webhooks. When a member joins your site via an affiliate link, the member.created or subscription.created webhook triggers affiliate tracking and commission calculation.
Can I track subscription renewals? ▼
Yes! AffiliateBase tracks Memberstack subscription renewals automatically through the payment.succeeded webhook. When a member's subscription renews, the original affiliate receives commission for the renewal, ensuring they're rewarded for recurring revenue.
What happens when a member upgrades or downgrades? ▼
AffiliateBase tracks membership changes through the subscription.updated webhook. The original affiliate maintains attribution, and commissions can be calculated based on the upgrade amount or new subscription level.
Does it work with Webflow and Framer? ▼
Yes! Since Memberstack integrates with Webflow and Framer, AffiliateBase works seamlessly with membership sites built on these platforms. The webhook integration works regardless of your frontend platform.
Can I set different commission rates for different membership tiers? ▼
Yes! You can configure different commission structures in AffiliateBase based on membership tier, plan, or price. This gives you full control over your affiliate program.
How do I add affiliate tracking to my Memberstack sign-up URLs? ▼
Add affiliate tracking parameters to your Memberstack sign-up URLs (e.g., ?ref=AFFILIATE_ID). AffiliateBase will capture these parameters and attribute conversions correctly when members join.
Related Platform Guides
Create an Affiliate Program with MemberPress
Complete guide to setting up an affiliate program with MemberPress. Track membership sign-ups, renewals, and upgrades using AffiliateBase and Stripe integration.
Create an Affiliate Program with Memberful
Complete guide to setting up an affiliate program with Memberful. Track membership sign-ups, subscriptions, and upgrades using AffiliateBase and webhooks.
Create an Affiliate Program with Next.js
Complete guide to setting up an affiliate program in Next.js. Step-by-step integration with code examples and best practices for Next.js developers.
Create an Affiliate Program with Nuxt
Complete guide to setting up an affiliate program in Nuxt. Step-by-step integration with Nuxt 3, server routes, and composables for Vue developers.
Create an Affiliate Program with WordPress
Complete guide to setting up an affiliate program in WordPress. Step-by-step integration with plugins, themes, and Stripe for WordPress SaaS and membership sites.
Ready to Launch Your Memberstack Affiliate Program?
Get started with AffiliateBase today and start growing your Memberstack membership site through affiliate marketing.