[affiliate_conversion_script] shortcode

Do you need to track referrals on custom success pages where purchases, signups, or other conversions occur? The [affiliate_conversion_script] shortcode allows you to generate referral records when visitors complete an action on your site after arriving via an affiliate referral link. This is useful for tracking successful transactions outside of AffiliateWP’s standard integrations, ensuring that affiliates are properly credited for referred conversions.

This guide explains how to use the [affiliate_conversion_script]shortcode, its parameters, and how to dynamically pass values through query strings.

How the [affiliate_conversion_script] Shortcode Works

When a visitor clicks an affiliate referral link and successfully completes a purchase, signup, or another defined conversion action, you can place the [affiliate_conversion_script] shortcode on your “success” page to generate a referral for the affiliate. This ensures that even custom checkout or signup flows outside of traditional eCommerce integrations can still track referrals properly.

To use the shortcode effectively, add it to the thank you or confirmation page where visitors land after completing a transaction.

Configuring the Shortcode Parameters

The [affiliate_conversion_script] shortcode supports multiple parameters to define referral details:

  • Amount – Defines the total purchase amount the referral is based on. The affiliate’s referral rate will determine the commission from this amount.
  • Description – Adds a custom description to the referral record for tracking purposes.
  • Context – Identifies the context of the referral (useful for tracking multiple forms or purchase types).
  • Reference – A unique reference ID for the transaction, such as a user ID or order number.
  • Status – Sets the referral status. Options include pending, unpaid, paid, or rejected. By default, it is set to pending.
  • Type – Defines the referral type. Options include sale, lead, or opt-in. By default, it is set to sale.

Example Shortcode Usage

[affiliate_conversion_script amount="10" description="My Description" context="Contact Form" reference="1234" status="pending" type="lead"]

This example creates a referral with:

  • A $10 purchase amount
  • The description “My Description”
  • The context “Contact Form”
  • The reference ID 1234
  • A status of pending
  • A referral type of lead

Key Considerations When Using This Shortcode

To ensure proper functionality, keep these key points in mind:

  • The shortcode should only be placed on success pages – It should be added to the confirmation page customers land on after completing a purchase, signup, or another conversion event.
  • A referral can only be created once per visitor while the tracking cookie is active – If a visitor returns while their affiliate tracking cookie is still valid, no new referral will be generated.
  • Shortcode formatting is critical – Ensure spaces are correctly placed between parameters. Improper formatting may cause blank values or a zero referral amount.
  • Coupons are not supported – Discount codes or coupons do not affect referral amounts when using this shortcode. If you need coupon-based tracking, consider using one of AffiliateWP’s supported integrations.

Passing Dynamic Values Through URLs

You can dynamically pass values to the shortcode using query strings in the URL. This is useful for automatically setting the referral amount and other parameters based on purchase details.

Example: Passing a Purchase Amount in the URL

https://yoursite.com/thanks/?amount=100

  • Here, yoursite.com/thanks/ is the purchase confirmation page where the shortcode is placed.
  • amount=100 dynamically sets the referral amount to $100.

Example: Passing Multiple Parameters in the URL

https://yoursite.com/thanks/?amount=100&description=My%20Description&context=Contact%20Form&reference=1234&status=pending&type=lead

This URL dynamically assigns values to amount, description, context, reference, status, and type based on the parameters passed in the query string.


That’s it! The [affiliate_conversion_script] shortcode is a powerful tool for tracking custom conversions on success pages. By placing it on your checkout or signup confirmation pages, you can ensure that affiliates are credited for referrals even when using custom transaction processes.