All Collections
PHP and Javascript Node Examples
PHP Nodes
Facebook ISP Redirection with a PHP Node
Facebook ISP Redirection with a PHP Node

Using a PHP node to redirect traffic based on an ISP filtering list

Zeno avatar
Written by Zeno
Updated over a week ago

In this article I will cover how to use a PHP node to elegantly redirect traffic coming from Facebook's automated review systems.

Note that this is not "cloaking" or some attempt at non-compliance, this is just smart redirection to ensure that automated checking systems don't get sent to affiliate links that you do not control, which have the annoying tendency to geo-redirect to unintended locations -- giving FB the impression that you are doing something that you're not actually doing (such as running a scammy sweepstakes offer).

This PHP code can be modified for other purposes as well, such as redirecting other ISPs you have flagged for some reason, or doing the same for referrers, device models, etc.

Step 1: Create your funnel and add a PHP node at the decision point

In most cases you’ll want to connect the traffic node to the PHP node, then connect ON DONE 1 to the pathway where matching (blocked/flagged) ISPs should go, and ON DONE 2 to the pathway you want normal users to go down.

See the example funnel diagram below, which shows a typical situation of rotating landers and offers.

Note, and this is important, in the side path for bots (those matching the ISP filter):

  • I still send them to a lander I am using in the live campaign as I want to provide the same destination as real users go to (not being misleading in FB’s eyes)

  • On clickthrough, I link it to the direct offer page URL with an external URL node. I do this so that they are guaranteed to see the right destination, not an affiliate link that could send them somewhere else. Remember, you don’t control where affiliate links from third parties will send people, and they could change at any time without you being alerted.

Step 2: Now that you have your funnel set up, alter the PHP node to do the filtering you want

Here’s the example code that will send visitors matching a list of IPs down the ON DONE 1 path, all others down the ON DONE 2 path.


$blocked_isps = array(
"digital ocean",
"trend micro",
"tata communications",
"innove communications",
"bharti infotel",
"spectramind eservices"

function filterMobileISP()
    if ("{connection-type}" == "Mobile") {
        $current_isp = "{connection-mobilecarrier}";
    } else {
        $current_isp = "{connection-isp}";
    return $current_isp;

function contains($current_isp, array $blocked_isps)
    foreach ($blocked_isps as $a) {
        if (stripos($current_isp, $a) !== false) return 1;
    return 2;

$tokenToTest = filterMobileISP();
return contains($tokenToTest, $blocked_isps);


Let me quickly break down what this code does:

  1. It lists an array of ISP names stored under $blocked_isps. These are just fragments of names since one ISP can appear in multiple ways, e.g. Amazon, Amazon Inc., Amazon systems Inc., etc.

  2. It does a check of connection type. If mobile, it checks the carrier, else it checks for ISP. In FunnelFlux carrier and ISP are different attributes hence we account for this here. Whatever the result, it sets $current_isp to this.

  3. A function runs that checks if the “current ISP” matches any of the items in the “blocked ISPs” list. If there is a match it will return 1, which tells the PHP node to go to the Done 1 path. Otherwise it returns 2, going down the Done 2 path.

Hopefully you can see this is quite generic and you could repurpose this code to check almost anything, such as operating system, device type, etc. 

You can also use these PHP nodes to make more complex conditions easy -- for that head on over to our rule builder, which will help you generate the PHP code needed.

Here’s an example of how you could modify the above to send blacklisted user-agents down a specific path:


$blocked_ua = array(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36 QQBrowser/",
"Process/tools NetType/WIFI Language/en",
"SamsungBrowser/9.2 Chrome"

function filterUA()
    return $current_ua;

function contains($current_ua, array $blocked_ua)
    foreach ($blocked_ua as $a) {
        if (stripos($current_ua, $a) !== false) return 1;
    return 2;

$tokenToTest = filterUA();
return contains($tokenToTest, $blocked_ua);


Reach out if you have any specific redirection/filtering functionality you want to implement where you’re unsure about how to approach it.

Did this answer your question?