Redirecting users based on local weather - an advanced PHP node usage example

Zeno

Last Update 2 months ago

Want to redirect your visitors to different landers/offers based on their local weather?Whether this is even useful or not, this is a good way for us to demonstrate the power of PHP nodes as well as multiple output routes.
First, let me show you the funnel diagram:​
The traffic is first being filtered by that "Weather Based Routing" PHP node. It is then being sent to 2 different pages, depending on the result of that filter.If there's thunderstorm, the visitor will be sent to http://www.funnelflux.com/Otherwise, he will be sent to Google Image Search, and the search query will be filled with a description of the visitor's weather... So if the sky is clear, he will see images of clear skies! If there's a tornado, he will see images of tornados...Before I show you the content of that PHP node, give it a try and enter that funnel yourself by clicking here.What was the result? :-)So let's have a look at that custom routing filter... When I double click that node, a PHP editor pops up:​
I'll give you the full code below, but first I want to explain how the filter decides to route toward one node or another. It's really simple. Have a look at the 2 exit connections after the PHP node:​
They have a path number. Path 1 to go Google Image Search, and Path 2 to go to FunnelFlux's website.In order to route the traffic to one of these nodes, the PHP node just needs to return that number:return 1; ----> to follow path 1.return 2; ----> to follow path 2.You can have up to 64 exit connections per PHP node.It is then possible to create very complex logic depending on your own specific needs. Here a PHP developer can help you create elegant and powerful routing solutions that are not possible with a basic UI... or any other tracker for that matter.Furthermore, it's not shown here, but you can also use Javascript nodes in your funnels to execute Javascript code and redirect to different nodes by using the exact same return syntax.Here's the full code for that weather based redirect logic (it calls the OpenWeatherMap's API):
In the future we plan to have example PHP and JS nodes with basic UI elements to configure properties. This will suffice for small, simple functions but for advanced functionality we highly recommend letting a PHP developer get familiar with the capabilities of these nodes.

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us