The latest WordPress update introduced the ability to inject shortcodes into your WordPress website.  

A shortcode is a small piece of code (indicated by brackets like [this]) that performs a specific function on your site. Because we've already created the underlying code that executes a function, all that you'd need to do is indicate where the shortcode can retrieve the information. 

With shortcodes, you can:  

  • Create a customer
  • Indicate the customer type
  • Create a conversion
  • Determine the Currency
  • Set the conversion's Commission type
  • Among other functions listed in the WordPress integration guide

Pre-Requisites for tracking via shortcodes

There are two main requirements for using Tapfiliate shortcodes: 

  • The Thank you page must be located in WordPress. 
  • The conversion/customer data should appear in the URL after payment or submission. 

Many applications that users go through offer the option to redirect users to a Thank you page within your WordPress set up, and allow you to output conversion data in the URL. 

In the next sections of this article, we'll illustrate how to use shortcodes to retrieve conversion data.

How to track Conversions and Customers with shortcodes

1. Set up your redirect URL

Let's say that you have: 

  • A WordPress website
  • And use Chargebee to process one-off payments for a fixed-price product.

In this case, you have to make sure of the following: 

  • That after payment the user is redirected to your WordPress Thank you page. 
  • That the order data (external id, customer id) is outputted in the URL. 

To set up your redirect and compose your URL with query parameters, you must find a page where you can compose a hosted URL redirect link containing query parameters. 

In Chargebee, for example, this page looks something like this: 

Here you can enable and compose the Redirect URL pointing to your Thank You page on WordPress - with query parameters attached, of course!

How to add your query parameters to our URL

In the redirect URL box, indicate the URL of your success page. 

Then, attach your query parameters and variables. 

Let's say we want to retrieve these details, and need fitting variables that help us fetch that data: 

  • Customer id
  • External id

Chargebee lets us know that they have corresponding variables that can be added to the URL:

  • {{Subscription.id}}
  • {{invoice.id}}

Because amount is a fixed amount, we'll add that inside the short code later. 

For now, focus on composing your URL like this: 

https://yoursite.com/success-page/?sub_id={{subscription.id}}&invoice_id={{invoice.id}} 

That way, when a purchase takes place, this information will output in the URL when the user is redirected to your WordPress Thank You page.  

2. Create your shortcode

Once your redirect URL is composed and ready, you can create your Tapfiliate shortcode. The shortcode must be added to the Thank You page the user is being redirected to. 

To compose a shortcode for this use case, do the following: 

  1. Start by writing [tapfiliate] 
  2. Next, we attach the relevant shortcode arguments. We want to retrieve the customer id and external id from the URL. Therefore, we take a look at the list of arguments and identify the ones we need for our shortcode.

    In this case, these are: customer_id_query_param  & external_id_query_param . Add these arguments to your short code. 
  3. The shortcode should now look like this: [tapfiliate customer_id_query_param= external_id_query_param= ] 
  4. The query parameters containing the data we'd like to include are still missing. We can add them by indicating the query parameter in the URL that retrieves the conversion information. These are "sub_id"  & "invoice_id" . Attache these to the corresponding arguments. 
  5. The shortcode should then look like this:
    [tapfiliate customer_id_query_param="sub_id" external_id_query_param="invoice_id"] 
  6. We still need to attach the conversion amount. Because it's always a fixed amount of $10, we write amount="10"  directly into the shortcode. We can also indicate the currency by passing the ISO code explicitly: currency="USD" 
  7. The shortcode in the Thank you page would then look like this: 
[tapfiliate customer_id_query_param="sub_id" external_id_query_param="invoice_id" amount="10" currency="USD"]


When a conversion takes place, this shortcode will then register a customer and a conversion for a $10 USD transaction.

What if I'm tracking leads or trials? 

It's also possible to track leads or trials using shortcodes

To do so, you'll format your redirect URL so that it outputs a customer id as a query parameter, like so: 

https://yoursite.com/success-page/?sub_id={{subscription.id}} 

Then, you need to use the customer_type  shortcode to indicate the type of customer you'd like to register in Tapfiliate. This can be either a "trial"  or a "lead" , depending on your specific use case. 

The shortcode on your WordPress thank you page would look like this: 

[tapfiliate customer_type="trial" customer_id_query_param="sub_id"] 

How do I add conversions when a payment takes place? 

  • Our article on lead and trial tracking explains the ways in which you can add conversions when a payment or purchase takes place. 

Bear in mind that depending on your use case, you may need a developer to help set this up for you. 

Did this answer your question?