Custom redirect results / landing page

Please read this blog post on how to work with custom result redirect / landing pages in general, then head over to the GitHub link below to grab your free sample code.

Just a few lines – you can find a full example on GitHub.

<?php 
$riddle = json_decode($_REQUEST['data']); 
?><p>
    You played <strong><?php echo $riddle->riddle->title; ?></strong><br>
    with the RIDDLE ID <strong><?php echo $riddle->riddle->id; ?>
</p>
<pre>
    <?php var_dump($riddle); /* debug complete data */ ?>
</pre>

When working with result redirect pages in WordPress you need to add a PHP file outside of WordPress to capture the data. Unfortunately it is not possible to send data via POST to a WordPress page.

To build result redirect pages you need to:

  1. Create a PHP file to capture the data from the Riddle and upload that to a directory on your server outside of WordPress (in a sub directory called Riddle for example).
  2. Open a session and store the data you want to use on the custom result page in a session variable
  3. Redirect to the WordPress page where you want to display the results in your PHP
  4. Add PHP code to your landing page in WordPress to process the data from the session variable and display it

Below is sample code you can use to grab the data from a Riddle and pass that on to a WordPress page. This is the code we use on our sample site Pastafun.com.

The example on Pastafun is based on a quiz with 2 possible results “Amateur Cook” and “Pro Cook” and redirects based on the score of the Riddle. Anyone with a score of 0 or 1 is directed to the Amateur Cook landing page, anyone with a score of 2 goes to the Pro Cook. People with no score are redirected to the Amateur Cook page as a default. The score equals the number of correctly answered questions. There are lots of other score variables you could pick up from Riddle such as the score percentage, but I like to work off the number of correctly answered questions and use that to work out my own scale.

Best practices for testing and building your own result redirect page code

  • Use our pre-build result page to see all the data your Riddle generates. Follow these instructions on how to do that. This will give you all the data in an easy to read format.
  • Add a webhook to the Riddle to see all the data generated for each lead. The easiest way to do that is to generate a free webhook on https://webhook.site

Either of the 2 methods mentioned above will allow you to pick up the correct syntax to find the value stored in the $riddle variable.

As usual, if you need any help, just reach out to us via chat or at hello@riddle.com

Make sure to also check out our free online course on how to build custom result pages on the Riddle Quiz Marketing Academy.