Skip to content

AffiliateWP Automations

How to Log AffiliateWP Referrals to a Google Sheet Automatically

A spreadsheet is often where affiliate reporting really lives, whether for your accountant or your own forecasts. To log AffiliateWP referrals to a Google Sheet automatically, use Zapify's An affiliate earns a referral trigger with the Add a row to a spreadsheet action. AffiliateWP and Google Sheets are Zapify PRO integrations.

What this automation does

The automation is one trigger plus one action:

  • Trigger: An affiliate earns a referral (AFFWP_REFERRAL_CREATED, AffiliateWP)
  • Action: Add a row to a spreadsheet (GOOGLESHEETS_APPEND_ROW, Google Sheets)

Each time a referral is created, Zapify adds a row to your sheet with the details you choose.

PRO feature

AffiliateWP and Google Sheets are Zapify PRO integrations, 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 Google account with access to the spreadsheet, and its Spreadsheet ID, the long string in its URL between /d/ and /edit.

How to build the automation

Step 1: Connect Google Sheets

Google Sheets connects by signing in rather than pasting a key.

  1. Go to Settings → Connections.

Open the Connections tab

  1. Choose Google Sheets and click Add New.

Add the Google Sheets connection

  1. Sign in with the Google account that can edit your sheet and approve the permissions.

See Connections for how this works and how to reconnect one that expires.

Step 2: 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 Log referrals to Google Sheets.

Create a new automation

Step 3: 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.

Leave the filters on Any to log every referral. Keep Run for on The affiliate.

Step 4: Add the "Add a row to a spreadsheet" action

  1. Click Add Action.

Add an action

  1. Choose Google Sheets as the app.

Select Google Sheets as the action

  1. Select Add a row to a spreadsheet.

Select Add a row to a spreadsheet

Step 5: Configure the action

Field Required What it does
Connection Yes The Google account from Step 1.
Spreadsheet ID Yes The ID from the sheet's URL, the long string between /d/ and /edit.
Sheet name No The tab to append to. Defaults to the first one.
Columns Yes One entry per column, left to right.

Give the sheet a header row such as Referral, Affiliate, Amount, Status, Order, Source. Then add one Columns entry per column, in the same order:

  1. the Referral ID token
  2. the Affiliate ID token
  3. the Referral amount token
  4. the Referral status token
  5. the Referral reference (order ID) token
  6. the Referral context token

Complete the Add a row to a spreadsheet action

Step 6: 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 7: Test it

Make a test purchase through a test affiliate's link and check the sheet. Zapify → Logs shows the run too.

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 and the Add a row to a spreadsheet action, your records write themselves. Referrals change status as they are confirmed and paid, so also log payouts when they are paid.

FAQs

Is this free in Zapify?

No. AffiliateWP and Google Sheets are both Zapify PRO integrations and need an active Zapify PRO licence. Google Sheets also needs a Connection.

Why did the row land in the wrong columns?

The Columns entries are written left to right in the order you add them, so keep that order the same as the sheet's columns.

Will the status in the sheet update later?

No. The row records the status at the moment the referral was created. Log a second row on payment, as described in the linked guide.

Do I need to write any code?

No. Everything is configured visually in the Zapify builder.

Was this page helpful?