In this article, we will show you how you can create values dynamically and access them on your landers.
This can be useful, for example, when you have to communicate with an external API and pass the received data to your landers, or if you just want to access data from PHP functions.
For this you will add a PHP node and place it in your funnel before the landers that need them, as below:
Double-click the PHP node and enter the following code, it will allow you to access and save data in the "Accumulated URL Params" buffer:
<?php
require_once 'PHPNodeHelpers.php';
?>
Before the closing php tag ?>, you will then add the dynamic tokens you want to make accessible and save them like this:
<?php
require_once 'PHPNodeHelpers.php';
// Put whatever you need here:
$accuParams['curTime'] = date("Y-m-d H:i:s");
$accuParams['rand'] = rand();
$accuParams['unix-timestamp'] = time();
// Save your new key/value pairs in the accumulation buffer
foreach($accuParams as $key => $val)
{
PHPNodeHelpers::accumulateParam($key, $val);
}
?>
Close the PHP window and double click your lander's node.
Enable this option:
The lander will now receive the entire "Accumulated URL Params" buffer in its URL.
This buffer contains the data that was passed to the initial tracking URL, anything configured in your advanced funnel settings, and data from PHP nodes like above.
Because of this, you do not need to set some outgoing URL in the PHP node -- the node is already going to redirect to the lander node, you are just appending some URL parameters to the redirect result.
Note that the data will be appended using the key names set in $accuParams, e.g. from the above example you would get:
...&curTime=2017-12-21 17:07:32&rand=5647849234&unix-timestamp=1514191777...
Important Notes
Note that you can access all PHP functions within these nodes -- there are no specific limitations here, so you can treat this like executing PHP on your own server (well, that is what you are doing after all) but with the addition of some helpful FunnelFlux processing and helpers.
You can also use this PHP node to communicate with an external API. We will leave it to you to experiment with such approaches and to think about how you could use these in your campaign. We have a case study on an example here.
Just keep in mind that these PHP scripts need to execute completely before FunnelFlux will redirect to the next node. So, if communicating with an external API, this will dictate the wait time before a redirect happens.
This is an important consideration on both ends -- for you as you have to consider performance, and on FunnelFlux's end the system needs to wait for the code to finish since it may alter the Accumulated URL Params buffer or tracking-fields that are then used in subsequent nodes.
Using FunnelFlux Tokens
You can access all stored tracking field and attribute data for the current visitor using any FunnelFlux token - they are stored as you would expect, e.g.
<?php
// Here's how you would access FunnelFlux token data
$user_device = '{device-type}';
$country = '{location-countryname}';
$traffic-source-data = '{trackingfield-fieldname}';
// All data is stored under the exact same names as the lander/offer dynamic tokens.
?>
Think of these tokens as placeholders -- they are updated in the PHP code before it gets executed.
Have fun :-)