Skip to content

AffiliateWP Automations

How to Send a Thank-You Email to a Customer Who Buys Through an AffiliateWP Referral

Customers who arrive through an affiliate are new to you, so the first email matters. To send a thank-you email to a customer who buys through an AffiliateWP referral, use Zapify's An affiliate earns a referral trigger with Run for set to The referred customer, and the Send an email action. AffiliateWP is a Zapify PRO integration.

What this automation does

The automation is one trigger plus one action:

  • Trigger: An affiliate earns a referral (AFFWP_REFERRAL_CREATED, AffiliateWP)
  • Action: Send an email (WP_SEND_EMAIL, WordPress)

Each time a referral is created for a customer, Zapify emails that customer, even if they checked out as a guest without an account.

PRO feature

AffiliateWP is a Zapify PRO integration, so this automation needs an active Zapify PRO licence.

No Connection needed for AffiliateWP

AffiliateWP runs on your own site, so there is no API key to paste for it and nothing to set up under Settings → Connections.

Before you start

  • AffiliateWP installed and active.
  • A working mail setup so WordPress can send email.

How to build the automation

Step 1: Create a new automation

  1. In the WordPress admin, go to Zapify → Automations.
  2. Click Add New to open the builder.
  3. Name it clearly, such as Thank referred customers.

Create a new automation

Step 2: Add the "An affiliate earns a referral" trigger

  1. Click Add Trigger.

Add a trigger

  1. Choose AffiliateWP as the app.

Select AffiliateWP as the trigger

  1. Select An affiliate earns a referral.

Select An affiliate earns a referral

  1. Configure the trigger:
Field Required What it does
Referral type Yes Any type, or one of Sale, Opt-in or Lead. Types added by an AffiliateWP add-on appear here too.
Source Yes Any source, or the integration the referral came from, such as WooCommerce, Easy Digital Downloads or MemberPress.
Product ID No Only referrals that include this product, matched by the product's ID. Leave empty for every product.
Run for Yes The affiliate (the default) or The referred customer. This decides whose details the automation uses.

Set Run for to The referred customer. Choose Sale as the Referral type so only purchases count.

Step 3: Add the "Send an email" action

  1. Click Add Action.

Add an action

  1. Choose WordPress as the app.

Select WordPress as the action

  1. Select Send an email.

Select Send an email

Step 4: Configure the action

Field Required What it does
To Yes Recipient address. Comma-separate several, or insert a token.
Subject Yes The subject line.
Format Yes HTML (default) or Plain text.
Body Yes The message. Insert tokens with the {} button.
Cc / Bcc No Extra recipients.
From name / From email No Override the sender.
Reply to No Set where replies go.

Because a guest has no WordPress account, send to the Referred customer email token and not the User email token:

  • To: the Referred customer email token
  • Subject: Thanks for your order
  • Body: Thanks for buying {Referral products}. As a thank-you, use code WELCOME10 on your next order.

Complete the Send an email action

Step 5: Set the steps Live and save

Each trigger and action has its own Live / Off / Draft switch. A new automation starts as a Draft and does nothing until its steps are Live.

  1. Set the trigger and every action to Live.
  2. Click Save.

Set the automation live

Step 6: Test it

Make a test purchase through a test affiliate's link, as a guest and as a logged-in customer. Check that both emails arrive. Zapify → Logs shows each run.

Tokens you can use

The trigger offers the affiliate's details, the referral's details, and the user tokens.

Token What it holds
Affiliate ID The affiliate's numeric ID in AffiliateWP.
Affiliate status Their status: active, inactive, pending or rejected.
Affiliate referral URL Their personal referral link, ready to put in an email.
Affiliate payment email The address they get paid at.
Affiliate rate / Affiliate rate type Their commission rate and whether it is a percentage or a flat amount.
Affiliate earnings / Affiliate unpaid earnings What they have earned in total, and what is still waiting to be paid.
Referral ID The referral's numeric ID.
Referral amount The commission earned.
Referral type / Referral status Sale, opt-in or lead, and the status it has now.
Referral context The source of the referral, such as woocommerce or edd.
Referral reference (order ID) The order or record the referral was earned from.
Referral description The description AffiliateWP saved with it.
Referral products The products on the referral, as a readable list.
Referred customer email The customer's email, when AffiliateWP recorded one.
User ID / Username / User email The user the automation runs for: the affiliate, or the referred customer when Run for is set to the customer.
Display name / First name / Last name Their name details.

Conclusion

With the An affiliate earns a referral trigger on The referred customer and the Send an email action, referred customers are welcomed whether or not they have an account. To reward the affiliate as well, see emailing the affiliate about the referral.

FAQs

Is this free in Zapify?

The Send an email action is free, but the AffiliateWP trigger is part of the AffiliateWP PRO integration and needs an active Zapify PRO licence.

How does it handle guest customers?

The automation runs without a user for a guest, so use the Referred customer email token for the recipient.

What if AffiliateWP did not record a customer?

Then the automation still runs but the Referred customer email token is empty, and the email action reports that the address is empty.

Can the user tokens be used here?

When the customer has an account, yes. They then describe the customer, not the affiliate.

Do I need to write any code?

No. Everything is configured visually in the Zapify builder.

Was this page helpful?