Routing multiple geos using a PHP node
A condition node has a yes route and a no route.
Chaining “If Canada”, then “If France”, then “If Australia” gets hard to manage when you need many countries.
Use one PHP node and a switch statement instead. The code returns an On Done number, and the visitor follows the connection with that number. See PHP node helper functions for how routes are chosen.
This example routes on country code:
<?php
$country_code = '{location-countrycode}';
// route geos to different On Done connectionsswitch ($country_code) { case 'US': case 'CA': case 'GB': case 'NZ': case 'AU': return 2; case 'DE': return 3; case 'FR': return 4; default: return 1; // default route}
?>The sample does this:
- It sets
$country_codeto the{location-countrycode}token. FunnelFlux replaces tokens before the code runs. You can use any FunnelFlux token. - It switches on
$country_code. US,CA,GB,NZandAUgo down On Done 2.DEgoes down On Done 3.FRgoes down On Done 4.- Any other value goes down On Done 1.
Always keep a default case.
If the code returns a number with no connection, the visitor follows the connection with the lowest On Done number.
You can use the same pattern for any token value. It collapses many conditions into one node.
You can connect the On Done connections to rotators, so each route sends visitors to a set of pages. Splitting traffic this way also makes each group easier to compare in your reports.

