Skip to content

Protecting your lander from direct traffic

To stop visitors opening a lander directly, or skipping the intended flow, put a PHP node in the funnel before the lander. That node creates a signed token that expires. FunnelFlux passes the token to the lander in its URL. The lander checks the token and loads only when it is valid, so a direct visit to the lander URL is rejected.

Funnel canvas with the Lander token PHP node between Entrance and the Widget Review lander, followed by the Widget Pro offer

The PHP node and the lander share a secret key. Generate a long random one, for example on your server:

Terminal window
openssl rand -hex 32

Keep the secret private. Anyone who knows it can create valid tokens.

Open the funnel settings, expand Advanced settings and add these lines under Custom tokens:

lander-token-secret=PASTE_YOUR_SECRET_HERE
lander-token-hours=24

lander-token-hours sets how long a token stays valid.

Funnel settings Advanced settings with Custom tokens lander-token-secret and lander-token-hours=24

Add a PHP node before the lander and connect it to the lander.

Funnel builder canvas right-click menu with Add Lander, Add Offer, Add Rotator, Add Condition, Add External URL and the Advanced submenu with Add JS Code, Add PHP Code and Add Visitor Tag

Use this code in the PHP node:

<?php
require_once 'PHPNodeHelpers.php';
$secret = '[[lander-token-secret]]';
$hours = '[[lander-token-hours]]';
$hours = is_numeric($hours) ? (int) $hours : 24;
// Token: expiry time, funnel ID and a signature over both
$payload = (time() + $hours * 3600) . '.' . '{funnel-id}';
$signature = hash_hmac('sha256', $payload, $secret);
PHPNodeHelpers::accumulateParam('ff_token', $payload . '.' . $signature);
?>

The code adds ff_token to the Accumulated URL Params buffer and keeps the other values in it. The signature ties the token to this funnel, so a token from another funnel is rejected.

Right-click the lander node, choose Advanced Settings and turn on Pass accumulated URL parameters. The lander URL then carries ff_token.

How accumulated URL parameters work.

Advanced funnel settings window for a lander node with Pass accumulated URL parameters switched on and the URL tokens section

The lander must run PHP. Place this at the very top of the lander file, before <!DOCTYPE html>:

<?php
$secret = 'PASTE_YOUR_SECRET_HERE';
$funnel_id = 'YOUR_FUNNEL_ID';
$valid = false;
$parts = explode('.', $_GET['ff_token'] ?? '');
if (count($parts) === 3) {
[$expires, $token_funnel_id, $signature] = $parts;
$expected = hash_hmac('sha256', $expires . '.' . $token_funnel_id, $secret);
$valid = hash_equals($expected, $signature)
&& $token_funnel_id === $funnel_id
&& ctype_digit($expires)
&& (int) $expires >= time();
}
if (!$valid) {
http_response_code(403);
exit('Invalid token');
}
?>

Set $secret to the same secret as the custom token, and $funnel_id to the ID shown in the Funnel ID field of the funnel settings.

To accept tokens from any funnel that uses the same secret, remove the && $token_funnel_id === $funnel_id line.

Send visitors to the lander through your FunnelFlux entrance link. A direct visit to the lander URL has no valid token, so the lander rejects it.

A token stays valid until it expires. Someone who copies a full lander URL, token included, can open it until then. Use a shorter lander-token-hours if that matters.