WordPress powers over 40% of the web, making it the most popular content management system. If you're running a WordPress site and want to monetize it through an affiliate program, AffiliateBase makes it simple.
This comprehensive guide will walk you through everything you need to know about setting up an affiliate program with WordPress, from adding the tracking script to integrating with WooCommerce and membership plugins.
Whether you're running a blog, membership site, or WooCommerce store, an affiliate program can help you grow your audience and increase revenue.
Follow these steps to integrate AffiliateBase with your WordPress site:
Add the Tracking Script
<script>(function(w,r){w._abq=w._abq||[];w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'affiliatebase');</script>
<script async src="https://cdn.jsdelivr.net/npm/affiliatebase-tracking@1/src/index.js" data-org-id='YOUR_ORG_ID'></script>
Add via functions.php (Alternative)
// Add to your theme's functions.php
add_action('wp_head', function() {
?>
<script>(function(w,r){w._abq=w._abq||[];w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}})(window,'affiliatebase');</script>
<script async src="https://cdn.jsdelivr.net/npm/affiliatebase-tracking@1/src/index.js" data-org-id='YOUR_ORG_ID'></script>
<?php
});
Integrate with Stripe
// WooCommerce: Add referral ID to order meta
add_action('woocommerce_checkout_create_order', function($order) {
if (isset($_COOKIE['affiliatebase_referral'])) {
$order->update_meta_data('_affiliatebase_referral',
sanitize_text_field($_COOKIE['affiliatebase_referral']));
}
});
// For Stripe Checkout: Pass as client_reference_id
// This requires custom Stripe integration code
Add Stripe Payment Links Support (Optional)
<!-- Add to your site alongside the tracking script -->
<script>
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
const referralId = window.affiliatebase_referral || '';
if (!referralId) return;
// Update Stripe Payment Links
document.querySelectorAll('a[href^="https://buy.stripe.com/"]').forEach(link => {
const url = new URL(link.href);
if (!url.searchParams.has('client_reference_id')) {
url.searchParams.set('client_reference_id', referralId);
link.href = url.toString();
}
});
// Update Stripe Pricing Tables
document.querySelectorAll('stripe-pricing-table').forEach(table => {
table.setAttribute('client-reference-id', referralId);
});
// Update Stripe Buy Buttons
document.querySelectorAll('stripe-buy-button').forEach(button => {
button.setAttribute('client-reference-id', referralId);
});
}, 1500);
});
</script>
Test Your Integration
// Visit your site with a test affiliate link:
// https://yoursite.com?via=test123
// Check browser console:
console.log(window.affiliatebase_referral); // Should show "test123"
Why Use AffiliateBase with WordPress?
AffiliateBase is the perfect solution for WordPress site owners who want to launch an affiliate program quickly.
Easy Installation
Add a single script tag to your WordPress site. No plugin required.
WooCommerce Compatible
Works with WooCommerce for tracking affiliate sales and commissions.
Membership Plugin Support
Integrates with popular membership plugins like MemberPress, Restrict Content Pro, and more.
Stripe Integration
Track conversions from Stripe payments on your WordPress site.
Frequently Asked Questions
Do I need a WordPress plugin for AffiliateBase?
Does AffiliateBase work with WooCommerce?
Can I use AffiliateBase with membership plugins?
What tracking parameters does AffiliateBase support?
Related Platform Guides
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 Webflow
Complete guide to setting up an affiliate program in Webflow. Step-by-step integration with Webflow CMS, custom code, and forms for no-code developers.
Create an Affiliate Program with React
Complete guide to setting up an affiliate program in React. Step-by-step integration with React hooks, context, and components for React developers.
Create an Affiliate Program with Vue
Complete guide to setting up an affiliate program in Vue. Step-by-step integration with Vue 3, composables, and plugins for Vue developers.
Ready to Launch Your WordPress Affiliate Program?
Get started with AffiliateBase today and start growing your WordPress site with affiliate marketing.