Until my upgrade to Piwik 1.1.1 (from 1.0) I was using link-tracking to track the effectiveness of my newsletters and redirects.
I would typically sent links like
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' || !empty($_SERVER['QUERY_STRING'])) {
ob_start();
include '/path-to-/piwik.php';
ob_get_clean(); // this discards the HTTP response and image returned
// do your redirect here
header("Location: " . $YOUR_URL_HERE );
exit;
}
p.s. the redirect parameter was deprecated and undocumented, and finally, removed in 1.1.
My redirect.php (in the same folder as piwik.php):
<?php
/*
* Fall-back for the removed redirect function of Piwik.
* See http://forum.piwik.org/read.php?2,71128,71154 .
*/
if(!empty($_SERVER['QUERY_STRING']) AND (!empty($_REQUEST['link']) OR !empty($_REQUEST['download']))) {
ob_start();
require './piwik.php';
ob_get_clean(); // Discard the HTTP response and image returned
// Determine new link
$sURL = (!empty($_REQUEST['link']) ? $_REQUEST['link'] : $_REQUEST['download']);
// Redirect
header('HTTP/1.1 303 See Other');
header('Content-Type: text/html; charset=UTF-8');
header('Location: '.$sURL);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'.PHP_EOL.
'<html><head><title>Redirect</title></head><body>'.PHP_EOL.
'<p>See <a href="'.htmlentities($sURL).'">'.htmlentities($sURL).'</a>.</p>'.PHP_EOL.
'</body></html>';
exit(0);
}else{
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: text/html; charset=UTF-8');
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'.PHP_EOL.
'<html><head><title>Redirect error</title></head><body>'.PHP_EOL.
'<p>The server couldn\'t understand your request.</p>'.PHP_EOL.
'</body></html>';
exit(1);
}
The cross-site referencing problem (that was probably the reason for deletion) stays in tact this way! More checks (to prevent this) could be added easily.