stripe-affiliate-integration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStripe Affiliate Integration
Stripe 联盟计划集成
This skill guides you through setting up Affonso affiliate tracking with Stripe payment integration.
本Skill将指导您完成Affonso联盟追踪与Stripe支付的集成设置。
Overview
概述
Affonso is an affiliate program platform that tracks referrals and commissions. This skill helps implement:
- Tracking script installation - Monitor affiliate traffic and conversions
- Stripe integration - Pass referral data to Stripe for commission tracking
- Optional features - Signup tracking, GTM integration, GDPR compliance
Affonso是一个用于追踪推荐和佣金的联盟计划平台。本Skill可帮助实现:
- 追踪脚本安装 - 监控联盟流量和转化
- Stripe集成 - 将推荐数据传递给Stripe以进行佣金追踪
- 可选功能 - 注册追踪、GTM集成、GDPR合规
Prerequisites & Information Gathering
前提条件与信息收集
Before beginning implementation, gather the following information by asking the user:
在开始实施之前,请通过询问用户收集以下信息:
Required Information
所需信息
-
Program ID: Ask "What is your Affonso program ID? You can find it at https://affonso.io/app/affiliate-program"
-
Cookie Duration: Ask "How many days should the affiliate tracking cookie persist? (Common values: 30, 60, 90 days)"
-
Stripe Integration Method: Ask "How do you communicate with Stripe?" Provide options:
- Stripe Checkout API
- Stripe Payment Links
- Stripe Buy Button
- Stripe Pricing Tables
- I don't know / Need help determining this
-
Google Tag Manager: Ask "Do you use Google Tag Manager to manage scripts on your website?"
-
Cookie Consent Banner: Ask "Do you use a cookie consent banner or need GDPR compliance?" If yes, follow up with "Which cookie consent platform do you use?" (e.g., Cookiebot, OneTrust, CookieYes, custom solution)
-
计划ID:询问“您的Affonso计划ID是什么?您可以在 https://affonso.io/app/affiliate-program 找到它”
-
Cookie有效期:询问“联盟追踪Cookie的有效期应为多少天?(常见值:30、60、90天)”
-
Stripe集成方式:询问“您通过哪种方式与Stripe对接?”提供以下选项:
- Stripe Checkout API
- Stripe Payment Links
- Stripe Buy Button
- Stripe Pricing Tables
- 我不知道 / 需要帮助确定
-
Google Tag Manager:询问“您是否使用Google Tag Manager管理网站上的脚本?”
-
Cookie同意横幅:询问“您是否使用Cookie同意横幅,或者需要符合GDPR要求?”如果是,追问“您使用哪个Cookie同意平台?”(例如:Cookiebot、OneTrust、CookieYes、自定义方案)
Optional Features
可选功能
- Signup Tracking: Ask "Do you want to track user signups in addition to purchases? (Recommended - provides better insights on affiliate performance)"
- 注册追踪:询问“除了购买之外,您是否还想追踪用户注册?(推荐 - 可提供更深入的联盟效果洞察)”
Connect Payment Provider
连接支付提供商
If the user's Stripe account is not already connected in Affonso, tell them to do this before or alongside the code integration:
- Go to https://affonso.io/app/affiliate-program/connect
- Select Stripe
- Enter the Stripe API key
- Copy the webhook URL that Affonso provides
- Add that webhook URL in the Stripe dashboard
If Stripe is already connected, continue with the code changes and keep the existing webhook connection in place.
如果用户的Stripe账户尚未在Affonso中连接,请告知他们在代码集成之前或同步完成此操作:
- 访问 https://affonso.io/app/affiliate-program/connect
- 选择Stripe
- 输入Stripe API密钥
- 复制Affonso提供的webhook URL
- 在Stripe仪表板中添加该webhook URL
如果Stripe已连接,请继续进行代码修改,并保留现有的webhook连接。
Workflow Decision Tree
工作流决策树
1. Connect Stripe to Affonso if it is not connected yet
2. Install Tracking Script
├─ Uses GTM? → See GTM Integration Guide
├─ Has Cookie Consent? → See GDPR Consent Guide
└─ Neither → Direct script installation
3. Track Signups (Optional)
└─ Add signup tracking code
4. Pass Data to Stripe
├─ Checkout API → See Stripe Checkout API Guide
├─ Payment Links → See Payment Links Guide
├─ Buy Button → See Buy Button Guide
├─ Pricing Tables → See Pricing Tables Guide
└─ Don't Know → Help identify integration method
5. Test Integration
└─ Verify tracking works end-to-end1. 如果尚未连接,先将Stripe连接到Affonso
2. 安装追踪脚本
├─ 使用GTM? → 参见GTM集成指南
├─ 有Cookie同意? → 参见GDPR同意指南
└─ 都没有 → 直接脚本安装
3. 追踪注册(可选)
└─ 添加注册追踪代码
4. 将数据传递给Stripe
├─ Checkout API → 参见Stripe Checkout API指南
├─ Payment Links → 参见Payment Links指南
├─ Buy Button → 参见Buy Button指南
├─ Pricing Tables → 参见Pricing Tables指南
└─ 不知道 → 帮助确定集成方式
5. 测试集成
└─ 端到端验证追踪是否正常工作Step 1: Install Tracking Script
步骤1:安装追踪脚本
The tracking script monitors affiliate traffic and creates the cookie that gets passed to Stripe.
affonso_referral追踪脚本会监控联盟流量,并创建 Cookie,该Cookie会被传递给Stripe。
affonso_referralDecision: GTM vs Direct Installation
决策:GTM 与 直接安装
If user uses Google Tag Manager:
- Read and follow the GTM Integration Guide
- This includes instructions for creating the GTM tag, setting triggers, and publishing
If user does NOT use GTM:
- Continue with direct script installation below
如果用户使用Google Tag Manager:
- 阅读并遵循GTM集成指南
- 其中包含创建GTM代码、设置触发器和发布的说明
如果用户不使用GTM:
- 继续阅读下方的直接脚本安装说明
Direct Script Installation
直接脚本安装
Basic Installation (No Cookie Consent)
基础安装(无Cookie同意)
Add this script to the website's tag:
<head>html
<!-- Place in <head> tag -->
<script
async
defer
src="https://cdn.affonso.io/js/pixel.min.js"
data-affonso="YOUR_PUBLIC_PROGRAM_ID"
data-cookie_duration="YOUR_COOKIE_DURATION"
></script>- Replace with the user's program ID
YOUR_PUBLIC_PROGRAM_ID - Replace with the cookie duration (e.g.,
YOUR_COOKIE_DURATIONfor 30 days)30
将此脚本添加到网站的标签中:
<head>html
<!-- Place in <head> tag -->
<script
async
defer
src="https://cdn.affonso.io/js/pixel.min.js"
data-affonso="YOUR_PUBLIC_PROGRAM_ID"
data-cookie_duration="YOUR_COOKIE_DURATION"
></script>- 将替换为用户的计划ID
YOUR_PUBLIC_PROGRAM_ID - 将替换为Cookie有效期(例如:
YOUR_COOKIE_DURATION代表30天)30
GDPR/Cookie Consent Installation
GDPR/Cookie同意安装
If the user has a cookie consent banner, read and follow the GDPR Consent Guide which includes:
- How to enable consent mode with
data-requires-consent="true" - Integration code for popular consent platforms (Cookiebot, OneTrust, CookieYes, etc.)
- URL parameter propagation requirements
- Testing consent-based tracking
Consent-enabled script:
html
<script
async
defer
src="https://cdn.affonso.io/js/pixel.min.js"
data-affonso="YOUR_PUBLIC_PROGRAM_ID"
data-cookie_duration="YOUR_COOKIE_DURATION"
data-requires-consent="true"
></script>Then add consent callback integration based on their consent platform (see GDPR guide).
如果用户有Cookie同意横幅,请阅读并遵循GDPR同意指南,其中包含:
- 如何通过启用同意模式
data-requires-consent="true" - 主流同意平台的集成代码(Cookiebot、OneTrust、CookieYes等)
- URL参数传递要求
- 基于同意的追踪测试
启用同意模式的脚本:
html
<script
async
defer
src="https://cdn.affonso.io/js/pixel.min.js"
data-affonso="YOUR_PUBLIC_PROGRAM_ID"
data-cookie_duration="YOUR_COOKIE_DURATION"
data-requires-consent="true"
></script>然后根据他们的同意平台添加同意回调集成(参见GDPR指南)。
Step 2: Track User Signups (Optional)
步骤2:追踪用户注册(可选)
If the user wants to track signups, add this code after their user registration logic:
javascript
// After successful user registration
window.Affonso.signup(userEmail);Benefits of signup tracking:
- See which affiliates drive the most registrations
- Calculate conversion rates from clicks to signups
- Optimize funnel based on affiliate performance
如果用户想要追踪注册,请在其用户注册逻辑之后添加以下代码:
javascript
// After successful user registration
window.Affonso.signup(userEmail);注册追踪的优势:
- 查看哪些联盟客带来的注册量最多
- 计算从点击到注册的转化率
- 根据联盟表现优化转化漏斗
Step 3: Pass Referral Data to Stripe
步骤3:将推荐数据传递给Stripe
The tracking script creates an cookie that must be passed to Stripe. Implementation varies by Stripe integration method.
affonso_referral追踪脚本会创建 Cookie,必须将其传递给Stripe。具体实现方式因Stripe集成方式而异。
affonso_referralIdentify Stripe Integration Method
确定Stripe集成方式
If the user selected "I don't know", help them identify their integration method:
- Checkout API: They create Stripe sessions programmatically in backend code (Node.js, Python, PHP, etc.)
- Payment Links: They use links starting with that redirect to Stripe's hosted checkout
buy.stripe.com - Buy Button: They embed HTML elements on their website
<stripe-buy-button> - Pricing Tables: They embed HTML elements on their website
<stripe-pricing-table>
如果用户选择“我不知道”,请帮助他们确定其集成方式:
- Checkout API:他们在后端代码中以编程方式创建Stripe会话(Node.js、Python、PHP等)
- Payment Links:他们使用以开头的链接,重定向到Stripe托管的结账页面
buy.stripe.com - Buy Button:他们在网站上嵌入HTML元素
<stripe-buy-button> - Pricing Tables:他们在网站上嵌入HTML元素
<stripe-pricing-table>
Integration Guides
集成指南
Based on the identified method, read and implement the appropriate guide:
根据确定的方式,阅读并实施相应的指南:
Stripe Checkout API
Stripe Checkout API
When to use: User creates checkout sessions programmatically in backend code
Read Stripe Checkout API Guide which includes:
- How to pass cookie as metadata
affonso_referral - Framework-specific examples (Next.js, Node.js, Python, Ruby, PHP)
- Testing with server logs
Quick implementation (Next.js example):
javascript
import { cookies } from 'next/headers';
const cookieStore = await cookies();
const affonsoReferral = cookieStore.get('affonso_referral')?.value || '';
const session = await stripe.checkout.sessions.create({
// ... existing config
metadata: {
affonso_referral: affonsoReferral,
},
});适用场景:用户在后端代码中以编程方式创建结账会话
阅读Stripe Checkout API指南,其中包含:
- 如何将Cookie作为metadata传递
affonso_referral - 特定框架的示例(Next.js、Node.js、Python、Ruby、PHP)
- 使用服务器日志进行测试
快速实现(Next.js示例):
javascript
import { cookies } from 'next/headers';
const cookieStore = await cookies();
const affonsoReferral = cookieStore.get('affonso_referral')?.value || '';
const session = await stripe.checkout.sessions.create({
// ... existing config
metadata: {
affonso_referral: affonsoReferral,
},
});Stripe Payment Links
Stripe Payment Links
When to use: User has links starting with
buy.stripe.comRead Payment Links Guide which includes:
- Enhancement script that automatically appends to links
client_reference_id - How the script works and when it runs
- Testing procedures
适用场景:用户拥有以开头的链接
buy.stripe.com阅读Payment Links指南,其中包含:
- 自动向链接追加的增强脚本
client_reference_id - 脚本的工作原理和运行时机
- 测试流程
Stripe Buy Button
Stripe Buy Button
When to use: User has elements
<stripe-buy-button>Read Buy Button Guide which includes:
- Enhancement script that sets attribute
client-reference-id - Installation instructions
- Testing procedures
适用场景:用户拥有元素
<stripe-buy-button>阅读Buy Button指南,其中包含:
- 设置属性的增强脚本
client-reference-id - 安装说明
- 测试流程
Stripe Pricing Tables
Stripe Pricing Tables
When to use: User has elements
<stripe-pricing-table>Read Pricing Tables Guide which includes:
- Enhancement script that sets attribute
client-reference-id - Installation instructions
- Testing procedures
适用场景:用户拥有元素
<stripe-pricing-table>阅读Pricing Tables指南,其中包含:
- 设置属性的增强脚本
client-reference-id - 安装说明
- 测试流程
Step 4: Testing & Verification
步骤4:测试与验证
Test Tracking Script
测试追踪脚本
- Visit the website with test parameter:
yoursite.com?atp=test - Open browser DevTools → Application → Cookies
- Verify cookie is set (unless consent mode is enabled and consent not given)
affonso_referral - Check Affonso dashboard for test entry
- 携带测试参数访问网站:
yoursite.com?atp=test - 打开浏览器DevTools → 应用(Application) → Cookie
- 验证Cookie已设置(除非启用了同意模式且用户未给予同意)
affonso_referral - 在Affonso仪表板中检查测试记录
Test Stripe Integration
测试Stripe集成
For Checkout API:
- Trigger checkout flow and check server logs for
metadata: { affonso_referral: "..." }
For Payment Links, Buy Buttons, Pricing Tables:
- Inspect the enhanced elements/URLs to verify is added
client_reference_id - DevTools → Elements tab → Find the Stripe element and check attributes/URL
对于Checkout API:
- 触发结账流程,检查服务器日志中是否有
metadata: { affonso_referral: "..." }
对于Payment Links、Buy Buttons、Pricing Tables:
- 检查增强后的元素/URL,验证已添加
client_reference_id - DevTools → 元素(Elements)标签页 → 找到Stripe元素,检查属性/URL
End-to-End Test
端到端测试
- Visit site with parameter
?atp=test - Complete a purchase using a 100% discount code (for live testing without payment)
- Check Affonso dashboard to verify the conversion was tracked
- Verify the test affiliate received credit for the sale
Note: Stripe test mode transactions won't appear in Affonso - use discount codes on live mode or check server logs/element attributes.
- 携带参数访问网站
?atp=test - 使用100%折扣码完成购买(用于无需支付的正式环境测试)
- 检查Affonso仪表板,验证转化已被追踪
- 验证测试联盟客已获得该笔销售的佣金
注意: Stripe测试模式的交易不会出现在Affonso中 - 请在正式模式下使用折扣码,或检查服务器日志/元素属性。
GDPR Consent Testing
GDPR同意测试
If using consent mode:
- Visit site with - verify no cookie is set
?atp=test - Accept cookies through consent banner - verify cookie is now set
- Navigate between pages - verify parameter persists
affonso_id - Complete purchase - verify tracking works
如果使用同意模式:
- 携带访问网站 - 验证未设置Cookie
?atp=test - 通过同意横幅接受Cookie - 验证现在已设置Cookie
- 在页面间导航 - 验证参数持续存在
affonso_id - 完成购买 - 验证追踪正常工作
Troubleshooting
故障排查
Cookie Not Set
Cookie未设置
- Check that script is in tag
<head> - Verify program ID is correct
- If using consent mode, ensure is called after user accepts
window.affonsoConsentGranted()
- 检查脚本是否位于标签中
<head> - 验证计划ID是否正确
- 如果使用同意模式,确保在用户接受后调用
window.affonsoConsentGranted()
Stripe Not Receiving Data
Stripe未接收到数据
- Checkout API: Verify server code reads cookie and passes to metadata
- Payment Links/Buy Button/Pricing Tables: Check that enhancement script runs (look for event)
affonso_referral_ready - Inspect Network tab for script loading errors
- Checkout API:验证服务器代码读取了Cookie并将其传递到metadata中
- Payment Links/Buy Button/Pricing Tables:检查增强脚本是否运行(查找事件)
affonso_referral_ready - 检查网络(Network)标签页中是否有脚本加载错误
Tracking Not Appearing in Dashboard
追踪记录未出现在仪表板中
- Ensure Stripe is connected in Affonso dashboard. If not, connect it first at https://affonso.io/app/affiliate-program/connect and add the Affonso webhook in Stripe.
- For testing, use live mode with discount codes (test mode doesn't sync)
- Check that the purchase completed successfully in Stripe
- 确保Stripe已在Affonso仪表板中连接。如果没有,请先在 https://affonso.io/app/affiliate-program/connect 连接,并在Stripe中添加Affonso的webhook。
- 测试时,请使用带折扣码的正式模式(测试模式不会同步)
- 检查Stripe中的购买是否已成功完成
Additional Resources
更多资源
For framework-specific implementation guidance, the user can check:
- https://affonso.io/help/installation-guides (Next.js, React, Vue, WordPress, etc.)
如需特定框架的实施指导,用户可以查看:
- https://affonso.io/help/installation-guides (Next.js、React、Vue、WordPress等)
Next Steps
后续步骤
After successful integration:
- Set up affiliate recruitment and program rules in Affonso dashboard
- Create affiliate resources (landing pages, promotional materials)
- Monitor performance and optimize commission structure
集成成功后:
- 在Affonso仪表板中设置联盟客招募和计划规则
- 创建联盟资源(落地页、宣传材料)
- 监控表现并优化佣金结构