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:
Chargebee lets us know that they have corresponding variables that can be added to the URL:
Because amount is a fixed amount, we'll add that inside the short code later.
For now, focus on composing your URL like this:
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:
Start by writing
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:
external_id_query_param. Add these arguments to your short code.
The shortcode should now look like this:
[tapfiliate customer_id_query_param= external_id_query_param= ]
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
"invoice_id". Attache these to the corresponding arguments.
The shortcode should then look like this:
[tapfiliate customer_id_query_param="sub_id" external_id_query_param="invoice_id"]
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:
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:
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.
In the case that you're also adding recurring commissions, please refer to the technical documentation on Recurring/lifetime commissions.
Bear in mind that depending on your use case, you may need a developer to help set this up for you.