### Affiliate Manager Program (Percentage) Source: https://docs.insertaffiliate.com/affiliate-commission Example setup for an affiliate manager program where the manager earns a percentage of their recruits' sales. This incentivizes recruitment. ```text Setup: - Manager recruits 10 affiliates - Each recruited affiliate configured with manager as parent - Manager earns 5% on all their recruits' sales Benefit: Incentivizes affiliate recruitment without reducing individual earnings ``` -------------------------------- ### Install Insert Affiliate SDK Source: https://docs.insertaffiliate.com/revenuecat-stripe-billing Install the Insert Affiliate SDK for JavaScript using npm. This is the first step to integrating affiliate tracking into your web checkout. ```bash npm install insert-affiliate-js-sdk ``` -------------------------------- ### Tiered Partnership Programs Source: https://docs.insertaffiliate.com/affiliate-commission Example setup for tiered partnership programs where higher-tier affiliates earn a percentage of their recruits' sales, creating growth incentives. ```text Setup: - VIP affiliates can recruit standard affiliates - VIP earns 8% on recruits' sales - Standard affiliates still earn full commissions Benefit: Creates growth incentives while maintaining competitive rates ``` -------------------------------- ### Common Event Examples - iOS Source: https://docs.insertaffiliate.com/event-tracking Examples of tracking common user actions like signup, trial activation, and profile completion using the iOS SDK. Ensure affiliate attribution is set. ```swift InsertAffiliateSwift.trackEvent(eventName: "user_signup") ``` ```swift InsertAffiliateSwift.trackEvent(eventName: "trial_started") ``` ```swift InsertAffiliateSwift.trackEvent(eventName: "profile_completed") ``` -------------------------------- ### Team-Based Structures Source: https://docs.insertaffiliate.com/affiliate-commission Example setup for team-based affiliate structures where a team lead earns a percentage of their team members' performance. This rewards leadership. ```text Setup: - Team lead manages team members - Members configured with lead as parent - Lead earns 7% on team performance Benefit: Rewards leadership without penalizing team members ``` -------------------------------- ### Agency/Reseller Model (Fixed Amount) Source: https://docs.insertaffiliate.com/affiliate-commission Example setup for an agency or reseller model where the agency earns a fixed amount per transaction from their client affiliates. This provides predictable earnings. ```text Setup: - Agency has multiple client affiliates - Each client configured with agency as parent - Agency earns a fixed $3.00 per transaction from each client's sales Benefit: Predictable per-sale earnings for the agency regardless of transaction size ``` -------------------------------- ### Example Affiliate Deep Link Source: https://docs.insertaffiliate.com/create-affiliate This is an example of a deep link that can be assigned to an affiliate. Ensure your generated link follows the expected format. ```plaintext https://insert.app.link/vessp13GH0lb ``` -------------------------------- ### Pass Affiliate and Company IDs to Backend Source: https://docs.insertaffiliate.com/stripe-web-transactions Send affiliate and company ID values to your backend when initiating the checkout session creation. This example uses a fetch POST request to a '/create-checkout-session' endpoint. ```javascript const response = await fetch('/create-checkout-session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ priceId: 'price_1234', insertAffiliate: affiliateId, insertAffiliateCompanyId: companyId, successUrl: window.location.origin + '/success', cancelUrl: window.location.origin + '/cancel', }), }); ``` -------------------------------- ### Initialize and Get Stripe Coupon Code with JS SDK Source: https://docs.insertaffiliate.com/discounts-for-end-users Initialize the Insert Affiliate SDK with your company code and retrieve the Stripe coupon code. Use 'getStripeCouponCode' or the more explicit 'getOfferCode(\'stripe\')'. Apply the retrieved coupon to your Stripe checkout session if one exists. ```javascript import { InsertAffiliate } from 'insert-affiliate-js-sdk'; // Initialize the SDK await InsertAffiliate.initialize('YOUR_COMPANY_CODE'); // Get the Stripe coupon code for the current affiliate const stripeCoupon = await InsertAffiliate.getStripeCouponCode(); // Or use the more explicit method with platform parameter const stripeCoupon = await InsertAffiliate.getOfferCode('stripe'); if (stripeCoupon) { // Apply the coupon to your Stripe checkout // Example using Stripe.js: const session = await stripe.checkout.sessions.create({ // ... your checkout config discounts: [{ coupon: stripeCoupon, }], }); } ``` -------------------------------- ### Get Current Offering with RevenueCat Targeting (Swift) Source: https://docs.insertaffiliate.com/discounts-for-end-users Use this code to retrieve the current offering from RevenueCat. RevenueCat's targeting rules will automatically apply the correct discounted offering based on user attributes like `affiliateOfferCode`. ```swift Purchases.shared.getOfferings { offerings, error in if let current = offerings?.current { // Display current.availablePackages // RevenueCat targeting automatically shows the right offering } } ``` -------------------------------- ### Daisy Chain Commission - Percentage Example Source: https://docs.insertaffiliate.com/affiliate-commission Demonstrates how a parent affiliate earns a percentage of the original sale amount when a child affiliate makes a sale. The parent's commission is independent of the child's earnings. ```text Original Sale: $100 Child Affiliate Rate: 15% Child Earns: $15 Daisy Chain Parent Percentage: 10% Parent Earns: $10 (10% of $100 original sale) Important: The parent's $10 does NOT come from the child's $15 Both earn their commissions independently from the original transaction ``` -------------------------------- ### Daisy Chain Commission - Fixed Amount Example Source: https://docs.insertaffiliate.com/affiliate-commission Shows how a parent affiliate earns a fixed dollar amount for each sale made by their child affiliate. This provides a predictable income stream for managers. ```text Original Sale: $100 Child Affiliate Rate: 15% Child Earns: $15 Daisy Chain Parent Fixed Amount: $5.00 Parent Earns: $5.00 per transaction ``` -------------------------------- ### Get Current Offering with RevenueCat Targeting (React Native) Source: https://docs.insertaffiliate.com/discounts-for-end-users This React Native code fetches the current offering from RevenueCat. The SDK automatically applies discounts based on RevenueCat's targeting rules, simplifying the display of available packages. ```javascript const offerings = await Purchases.getOfferings(); if (offerings.current) { // Display offerings.current.availablePackages // RevenueCat targeting automatically shows the right offering } ``` -------------------------------- ### Create Stripe Checkout Session with Affiliate Metadata Source: https://docs.insertaffiliate.com/stripe-web-transactions When creating a Stripe Checkout session, include affiliate and company ID metadata in the session, subscription, and payment intent configurations to ensure proper tracking. This example demonstrates passing these values during subscription checkout. ```javascript const session = await stripe.checkout.sessions.create({ line_items: [ { price: 'price_1234', quantity: 1, }, ], mode: 'subscription', success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', // 1. Session metadata (available in checkout.session.completed event) metadata: { insertAffiliate: insertAffiliate || '', insertAffiliateCompanyId: insertAffiliateCompanyId || '', }, // 2. Subscription metadata (persists with subscription) subscription_data: { metadata: { insertAffiliate: insertAffiliate || '', insertAffiliateCompanyId: insertAffiliateCompanyId || '', }, }, // 3. Payment Intent metadata (available on each payment) payment_intent_data: { metadata: { insertAffiliate: insertAffiliate || '', insertAffiliateCompanyId: insertAffiliateCompanyId || '', }, }, }); ``` -------------------------------- ### Get SHA-256 Fingerprint for Android Debug and Release Builds Source: https://docs.insertaffiliate.com/insert-links Use these keytool commands to retrieve your app's SHA-256 certificate fingerprint for debug and release builds. This is required for App Links configuration. ```bash # For debug builds keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android | grep SHA256 ``` ```bash # For release builds (use your keystore) keytool -list -v -keystore your-release-key.keystore -alias your-alias | grep SHA256 ``` -------------------------------- ### Initialize Insert Affiliate and RevenueCat SDKs Source: https://docs.insertaffiliate.com/revenuecat-web-billing Initialize both the Insert Affiliate SDK and the RevenueCat Web SDK. Ensure you use your company code for Insert Affiliate and your RevenueCat Web API key. ```javascript import { InsertAffiliate } from 'insert-affiliate-js-sdk'; import { Purchases } from '@revenuecat/purchases-js'; // Initialize Insert Affiliate SDK await InsertAffiliate.initialize('your_company_code'); // Initialize RevenueCat Web SDK const purchases = Purchases.configure('your_revenuecat_web_api_key'); ``` -------------------------------- ### Initialize Insert Affiliate SDK Source: https://docs.insertaffiliate.com/revenuecat-stripe-billing Initialize the Insert Affiliate SDK on your web checkout page. Ensure this is done before users complete their purchases. Requires your company code. ```javascript import { InsertAffiliate } from 'insert-affiliate-js-sdk'; // Initialize SDK with your company code await InsertAffiliate.initialize('your_company_code'); ``` -------------------------------- ### Basic Performance Ladder Commission Structure Source: https://docs.insertaffiliate.com/affiliate-commission Defines a tiered commission structure based on the number of sales within a month. This is a foundational example for performance-based incentives. ```text Default Rate: 2% Rule 1: 10% after 5 sales in a month Rule 2: 15% after 10 sales in a month ``` -------------------------------- ### Commission Calculation (Platform Fees Enabled) Source: https://docs.insertaffiliate.com/affiliate-commission When platform fee deduction is enabled, affiliate commission is calculated on the net amount after store fees are deducted. This example shows a 30% App Store fee. ```text Sale Price: $9.99 App Store Fee (30%): $3.00 Net Revenue: $6.99 Affiliate Rate: 10% Affiliate Commission: $0.70 (10% of $6.99) ``` -------------------------------- ### Manual Deep Link Entry for Affiliate Signup Source: https://docs.insertaffiliate.com/create-affiliate-affiliate-self-signup Use this format when providing a comma-separated list of deep links for affiliates if you are not using Branch.io. ```text https://your-deeplink.com/abc123, https://your-deeplink.com/xyz789 ``` -------------------------------- ### Enable Custom Deep Link on Signup Source: https://docs.insertaffiliate.com/create-affiliate-affiliate-self-signup Append `&deeplink=null` to your signup URL to allow affiliates to enter their own deep link during signup. This bypasses the unassigned deep link pool. ```url ...affiliate-signup-iframe?companyName=YOUR_COMPANY_NAME&deeplink=null ``` -------------------------------- ### Configure AndroidManifest.xml for App Links (Default Domain) Source: https://docs.insertaffiliate.com/insert-links Add this intent filter to your launcher activity to enable Android App Links for the default Insert Affiliate domain. Ensure android:autoVerify="true" is set. ```xml ``` -------------------------------- ### Create a Contact (cURL) Source: https://docs.insertaffiliate.com/contacts Add a new contact to your list. Requires the contact's username and phone number. An avatar URL and display name can optionally be provided. ```bash curl https://api.protocol.chat/v1/contacts \ -H "Authorization: Bearer {token}" \ -d username="FrankMcCallister" \ -d phone_number="1-800-759-3000" \ -d avatar_url="https://assets.protocol.chat/avatars/frank.jpg" ``` -------------------------------- ### Create a contact Source: https://docs.insertaffiliate.com/contacts Adds a new contact to your contact list. Requires the contact's Protocol username and phone number. ```APIDOC ## POST /v1/contacts ### Description This endpoint allows you to add a new contact to your contact list in Protocol. To add a contact, you must provide their Protocol username and phone number. ### Method POST ### Endpoint /v1/contacts #### Request Body - **username** (string) - Required - The username for the contact. - **phone_number** (string) - Required - The phone number for the contact. - **avatar_url** (string) - Optional - The avatar image URL for the contact. - **display_name** (string) - Optional - The contact display name in the contact list. By default, this is just the username. ### Request Example ```curl curl https://api.protocol.chat/v1/contacts \ -H "Authorization: Bearer {token}" \ -d username="FrankMcCallister" \ -d phone_number="1-800-759-3000" \ -d avatar_url="https://assets.protocol.chat/avatars/frank.jpg" ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the contact. - **username** (string) - The username for the contact. - **phone_number** (string) - The phone number for the contact. - **avatar_url** (string) - The avatar image URL for the contact. - **display_name** (string) - The contact display name in the contact list. - **conversation_id** (string) - Unique identifier for the conversation associated with the contact. - **last_active_at** (timestamp) - Timestamp of when the contact was last active on the platform. - **created_at** (timestamp) - Timestamp of when the contact was created. ### Response Example ```json { "id": "WAz8eIbvDR60rouK", "username": "FrankMcCallister", "phone_number": "1-800-759-3000", "avatar_url": "https://assets.protocol.chat/avatars/frank.jpg", "display_name": null, "conversation_id": "xgQQXg3hrtjh7AvZ", "last_active_at": null, "created_at": 692233200 } ``` ``` -------------------------------- ### Affiliate Signup Link Format Source: https://docs.insertaffiliate.com/affiliate-commission This is the format of the unique signup link affiliates use to recruit others. Replace AFFILIATE_SHORT_CODE with the recruiting affiliate's actual short code. ```html https://app.insertaffiliate.com/signup/affiliate?companyName=YourCompany&daisyChain=AFFILIATE_SHORT_CODE ``` -------------------------------- ### Track Custom Event - Unity Source: https://docs.insertaffiliate.com/event-tracking Use this function to track a custom event in your Unity application. Ensure the SDK is initialized and affiliate attribution is set. ```csharp InsertAffiliate.TrackEvent("user_signup"); ``` -------------------------------- ### Configure AndroidManifest.xml for Custom URL Schemes Source: https://docs.insertaffiliate.com/insert-links Add these intent filters to your launcher activity in AndroidManifest.xml to handle custom URL schemes. Ensure the scheme matches your Insert Affiliate Settings. ```xml android:exported="true" android:launchMode="singleTop"> /> ``` -------------------------------- ### Pass Affiliate Data During Purchase Source: https://docs.insertaffiliate.com/revenuecat-web-billing Retrieve affiliate and company IDs, then pass them as UTM parameters in the purchase metadata to RevenueCat. This ensures proper attribution for web subscriptions. ```javascript // Get the current affiliate identifier and company ID // Use ignoreTimeout: true to get the identifier even if attribution window expired const affiliateId = await InsertAffiliate.returnInsertAffiliateIdentifier(true); const companyId = await InsertAffiliate.returnCompanyId(); console.log('Affiliate ID:', affiliateId || 'none'); console.log('Company ID:', companyId || 'none'); // Prepare metadata with UTM parameters for RevenueCat Web Billing const metadata: Record = {}; if (affiliateId && affiliateId !== 'none') { metadata.utm_source = 'insertAffiliate'; metadata.utm_medium = companyId || 'none'; metadata.utm_campaign = affiliateId; } console.log('Purchase metadata:', JSON.stringify(metadata, null, 2)); // Get offerings and select a package const offerings = await purchases.getOfferings(); const selectedPackage = offerings.current?.availablePackages[0]; if (!selectedPackage) { console.error('No packages available'); return; } // Make the purchase with metadata const { customerInfo } = await purchases.purchase({ rcPackage: selectedPackage, metadata: metadata, }); console.log('Purchase successful!'); console.log('Active entitlements:', Object.keys(customerInfo.entitlements.active)); ``` -------------------------------- ### Append UTM Parameters to Web Purchase Links Source: https://docs.insertaffiliate.com/revenuecat-web-billing Append these UTM parameters to your RevenueCat Web Purchase Links for affiliate attribution. Ensure `utm_source` is 'insertAffiliate', `utm_medium` is your company ID, and `utm_campaign` is the affiliate's short code. ```url https://pay.rev.cat/sandbox/viqxbcoudyfaeaae/ ``` ```url ?utm_source=insertAffiliate&utm_medium={insertAffiliateCompanyId}&utm_campaign={affiliateShortCode} ``` ```url https://pay.rev.cat/sandbox/viqxbcoudyfaeaxa/?utm_source=insertAffiliate&utm_medium=12345&utm_campaign=AFF123 ``` -------------------------------- ### List All Contacts (cURL) Source: https://docs.insertaffiliate.com/contacts Retrieve a paginated list of all your contacts. The `limit` attribute can be used to control the number of contacts returned per page. ```bash curl -G https://api.protocol.chat/v1/contacts \ -H "Authorization: Bearer {token}" \ -d active=true \ -d limit=10 ``` -------------------------------- ### Configure AndroidManifest.xml for App Links (Custom Domain) Source: https://docs.insertaffiliate.com/insert-links If you use a custom domain for your Insert Links, add this intent filter to your launcher activity in AndroidManifest.xml. Ensure android:autoVerify="true" is set. ```xml ```