This site was built to showcase the power of Riddle.com for news websites.
It focusses on things like Ad Delivery (video and text ads) and handling logged in users.
Getting users create accounts and log in is a key focus area for many publishers to increase retention, personalise content and increase ad revenue.
This site explains the key techniques used to create The Daily Gladiator
Logged in user status and the Riddle Data Layer
Riddles Data Layer allows me to pass data from my site to Riddle and later retrieve that data again combined with the Riddle data.
To pass information like username, user email and logged-in status (0 or 1) to Riddle, I created a new shortcode in my functions.php.
I can call that shortcode whereever I place a Riddle that requires this data.
In Riddle, I used the project wide settings to set up unified data layer variables for logged-in status, user name and user email. That way my editors will never need to remember to add these variables to a Riddle. This is a feature of the Riddle Enterprise Plan.
Code Example
The code used to create the shortcode that grabs information from the logged-in user and passes it to the Riddle Data Layer. I have used the code provided on the Riddle Examples Page for Developers and altered it for WordPress. In addition to the user info, I am also passing the current page path to a data layer variable. This is useful if a Riddle is used on more than one page like the article rater you will find in every article side bar. Readers can rate the current article and Riddle will store the article name along with the vote.
				
					//**push to Riddle datalayer shortcode**//
function riddle_datalayer_shortcode() {
    if ( is_user_logged_in() ) {
        $current_user  = wp_get_current_user();
        $is_logged_in  = '1';
        $display_name  = esc_js( $current_user->display_name );
        $email         = esc_js( $current_user->user_email );
    } else {
        $is_logged_in  = '0';
        $display_name  = '';
        $email         = '';
    }
    // Print all pushes in one 
HTML;
}
add_shortcode('riddle_datalayer', 'riddle_datalayer_shortcode');