Skip to main content
All CollectionsPHP and Javascript Node ExamplesPHP Nodes
Redirect users from one funnel to another
Redirect users from one funnel to another
Zeno avatar
Written by Zeno
Updated over a week ago

Scenario

You are sending traffic to funnel A (to the traffic node).

You decide to make funnel B and want all funnel A traffic to jump to funnel B instead.


Solution

Connect the traffic node in funnel A to a PHP node, and have that PHP node route the traffic to funnel B.

Here is the code you should put in the PHP node:

<?php

require_once 'PHPNodeHelpers.php';

$trackingFields = PHPNodeHelpers::loadTrackingFields();
$currentTrafficSourceId = '{trafficsource-id}';
$targetFunnelId = '[[target-funnel-id]]';

$queryParams = $trackingFields;
$queryParams['flux_fts'] = Crypter::fastEncodeDigits( [$targetFunnelId, $currentTrafficSourceId] );
$url = 'http://{flux-domain}?'.http_build_query($queryParams);
Permalinks::fastRedirect( $url );

?>


Then, open the advanced settings of funnel A and you will need to define the ID of funnel B that it will be sending traffic to. 

You could also define it in the above code directly, but we like to declare this as a custom token so that the above code is reusable.

Solution 2 - if you want to send to a specific node ID

Connect the traffic node in funnel A to a PHP node in the same way.

Use this code in the PHP node instead:

<?php

require_once 'PHPNodeHelpers.php';

$trackingFields = PHPNodeHelpers::loadTrackingFields();
$currentTrafficSourceId = '{trafficsource-id}';
$targetFunnelId = '[[target-funnel-id]]'; //can also change this here
$targetNodeId = '[[target-node-id]]'; //can also change this here

$queryParams = $trackingFields;
$queryParams['flux_fts'] = Crypter::fastEncodeDigits( [$targetFunnelId, $currentTrafficSourceId] );
$queryParams['flux_fn'] = $targetNodeId;

$url = 'http://{flux-domain}?'.http_build_query($queryParams);
Permalinks::fastRedirect( $url );

?>

Here you can declare the flux_fn globally in the advanced settings > custom tokens box, like with funnel ID.

However, if you need these nodes to be specific or have multiple nodes in a funnel, you can simply write the funnel ID and node ID in the PHP code directly, e.g.

<?php

require_once 'PHPNodeHelpers.php';

$trackingFields = PHPNodeHelpers::loadTrackingFields();
$currentTrafficSourceId = '{trafficsource-id}';
$targetFunnelId = 'xxxxxxxxxxxx'; //can also change this here
$targetNodeId = 'xxxxxxxxxxxx'; //can also change this here

$queryParams = $trackingFields;
$queryParams['flux_fts'] = Crypter::fastEncodeDigits( [$targetFunnelId, $currentTrafficSourceId] );
$queryParams['flux_fn'] = $targetNodeId;

$url = 'http://{flux-domain}?'.http_build_query($queryParams);
Permalinks::fastRedirect( $url );

?>
Did this answer your question?