Scenario: You're promoting an offer that has a daily cap, network wide. When the offer reaches its maximum cap, the network automatically redirects to another offer that you can't or don't want to promote for a reason or another.

Is it possible to automatically redirect to an offer of your choice when the network switches to that other offer?

Answer: of course you can do that with FunnelFlux and its PHP Nodes!

The solution is to use a PHP Node before redirecting to offer 1, to check its page content. If some words are there on the page, then all is good and you can link to it. Otherwise, branch to another offer of your choice!


Here's how the funnel looks:


If some specific content is found on the page, redirect to offer 1. Otherwise redirect to offer 2.

Let's look at the PHP Node itself:

<?php

$url = "http://your-affiliate-link";
$contentThatMustBeHere = "the page content to check for";

$output = file_get_contents( $url );
if( strpos($output, $contentThatMustBeHere) !== false ) {    
    // content is here... follow route #1    
    return 1;
}

// content is NOT on target page, follow route #2
return 2;

?>


That makes this PHP Node check for the content of one specific offer page. It's not very flexible if you want to use that in different funnels, for different offers.

To make it more flexible, you may want to use the custom tokens feature in your funnels.

First open the advanced settings panel:


Enter those 2 custom tokens:

Then edit the PHP Node code to use these custom tokens instead of fixed values:

<?php

$url = "[[content-checker-url]]";
$contentThatMustBeHere = "[[content-checker-body]]";

$output = file_get_contents( $url );
if( strpos($output, $contentThatMustBeHere) !== false ) {    
    // content is here... follow route #1    
    return 1;
}

// content is NOT on target page, follow route #2
return 2;

?>


You can now use this same PHP Node in different funnels, for different offers.


Dealing with geo-redirection

Unfortunately, a lot of networks will geo-redirect users to random pages when they don't match the offer criteria.

There's two ways to approach this.

  1. Ask your affiliate network if there is a parameter you can add to turn this off. Sometimes you can add e.g. test=true  or preview=1 to your links to have them go direct to the offer in preview mode. This can work.
  2. Change the above approach to use cURL instead, and route the request through a VPN server for the appropriate country (a bit more work!).

For #2, check out this article for some guidance.

We don't yet have example code for doing this, and it will vary per provider, but we'll come up with something in the near future that uses something like VyprVPN.


Sending an email when things change

If you want to send yourself an email alert whenever the content is not found anymore on the page, you can add this in the PHP Node, just before the last "return 2;" (in FunnelFlux versions 1.6117 and above):

require_once 'PHPNodeHelpers.php';

PHPNodeHelpers::sendMail( [
'to' => 'you@you.com',
'email-subject' => 'Open this now',
'email-body' => 'The html email content',
'smtp-configuration' => [
   'server' => 'your-smtp.server.com',
   'port' => 'port number',
   'secure' => 'ssl',    // this can be '', 'ssl' or 'tsl'
   'username' => 'username to smtp service',
   'password' => 'password to smtp service',
   'from-name' => 'Me',
   'from-email' => 'me@me.com',
]
] );
Did this answer your question?