Creating custom landing pages for affiliates

This is an advanced tutorial which requires changes to your website. ThriveCart will not be held responsible for any issues with your website trying to implement this. You may wish to refer to a developer for assistance.

Who is this tutorial for?

If you want to have a different landing page for different affiliates on your website. Your affiliates use the standard ThriveCart affiliate link from their dashboard, but depending on the affiliate will depend on where your affiliates traffic is taken to.

How does it work?

When ThriveCart redirects users to your product’s target URL it includes a query string with the referring affiliate’s ID. A small script on your page will then read this query string, check the affiliate ID and if it matches a preset value, it then redirects to a different URL assigned to that value.

This means your affiliates simply have to use the affiliate link provided to them in ThriveCart (https://affiliateid–youraccount.thrivecart.com/product-name/) and your site will check and then take users to a dedicated page for the specific referring affiliate.

Let’s look at the code

We’re going to use some simple PHP to read the query string, check the affiliate ID and then redirect to a URL for that specific ID.

You’ll need to embed this PHP code into your web page. If you are using WordPress then you will need to add this to your theme’s functions.php file. If you are not sure what you are doing we highly recommend seeking guidance from a web developer.

Code example:

// ThriveCart custom affiliate sales pages
add_action('wp_enqueue_scripts', 'affiliateredirect');
function affiliateredirect() {

    $custom_sales_page = '';

    switch($_GET['affiliate']) {
      
        case 'affiliateidhere':
            $custom_sales_page = 'fullURLhere';
            break;
    }

    if(!empty($custom_sales_page)) {
        header("Location: {$custom_sales_page}");
    }
}

Line 9, you will want to replace affiliateidhere with the ID of the affiliate whose traffic you want to send to a custom URL. You can get this from your ThriveCart dashboard under your My affiliates area (their ID is shown in brackets next to their name)

Line 10, you will want to replace fullURLhere with the URL you want to send users to. Use the full URL.

Completed example:

// ThriveCart custom affiliate sales pages
add_action('wp_enqueue_scripts', 'affiliateredirect');
function affiliateredirect() {
    $custom_sales_page = '';
    switch($_GET['affiliate']) {
      
        case 'johnsmith':
            $custom_sales_page = 'https://yourwebsite.com/johnsmithslandingpage/';
            break;
    }
    if(!empty($custom_sales_page)) {
        header("Location: {$custom_sales_page}");
    }
}

We’ve now successfully set up a redirect that will only affect John Smith’s leads. When he sends traffic to your site using his affiliate link, his leads will be redirected to his own dedicated landing page. Other users will simply go to the main page set in your product settings in ThriveCart.

Having multiple custom affiliate pages

Let’s say you have several affiliates you want to send to their own pages on your site. You may have lots of affiliates, but 3 key affiliates that you want to have more personalised.

To do this we simply need to add multiple copies of

case 'affiliateidhere':
           $custom_sales_page = 'fullURLhere';
           break;

For example, the code with 3 custom affiliate redirects would look like

// ThriveCart custom affiliate sales pages
add_action('wp_enqueue_scripts', 'affiliateredirect');
function affiliateredirect() {
    $custom_sales_page = '';
    switch($_GET['affiliate']) {
      
        case 'affiliateid1':
            $custom_sales_page = 'fullURLhere';
            break;

        case 'affiliateid2':
            $custom_sales_page = 'fullURLhere';
            break;

        case 'affiliateid3':
            $custom_sales_page = 'fullURLhere';
            break;
    }
    if(!empty($custom_sales_page)) {
        header("Location: {$custom_sales_page}");
    }
}

Each section will have your affiliate’s ID and then the URL their traffic is redirected to.

Wrapping up

So now, once this code is saved on the “Affiliate target URL” page you’ve set in your products setting in ThriveCart, if one of the noted affiliates sends traffic to your site, they will be redirected to the new URL you’ve set. Any affiliates who are not mentioned here will carry on to the default URL.

Related Articles