I've set up an interstitial ad on my website (WordPress 3.3.2 on Nginx+PHP-FPM+MySQL) through the use of a little trick:
The index.php file checks if there is a new session, and in this case we load the interstitial and we set up a session cookie lifetime of 300 seconds (5 mins) in order to display the ad from time to time. The code is as follows:
Code:
<?php
ini_set('session.cookie_lifetime','300');
session_start();
if (!empty($_SESSION['count']) || stristr($_SERVER['REQUEST_URI'], 'feed')) {
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
} else if(empty($_SESSION['count'])){
$_SESSION['count'] = 1;
?>
... here goes the interstitial script ...
This makes the ad appear if there was a new session, or go to the content straight away if the session was still active and the counter is below that 300 seconds.
There's a little problem with this, though: Statcounter is counting much less pageviews and uniques that we really have, and I think there's some problem with the session.cookie_lifetime parameter.
I wonder if this is really the reason, or if you may know why the statistics aren't real... it's like if statcounter only is updated each 5 mins??? I really don't understand why is this happening.