Forum Moderators: skibum
I'm trying to use a PHP script to track my PPC Adwords traffic before these clicks are sent to CJ.com.
For tracking, I'm using the Google Analytics Javascript code snippet.
The problem is that if I use
Header("Refresh: 2;$url"); my tracking works but CJ.com fails to register any clicks, but if I use Header("Location: $url"); then CJ will register clicks but my tracking will fail. Any advice would be greatly appreciated, here is my code:
<?php
// GET PARAMS
$pid=$_GET['pid'];
$aid=$_GET['aid'];
$sid=$_GET['sid'];
$url=$_GET['url'];
if (strlen($sid) < 1){
$sid = 'organic';
}
// BUILD URL
$url = "http://www.dpbolvw.net/click-$pid-$aid?sid=$sid&url=$url";
// PRINT
echo '<p>Loading...</p>';
echo '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">';
echo '</script>';
echo '<script type="text/javascript">';
echo '_uacct = "UA-#*$!#*$!X-X";';
echo 'urchinTracker("/tracking/");';
echo '</script>';
// REDIRECT TO URL
Header("Location: $url");
//Header("Refresh: 2;$url");
exit;
?>
Thanks for your help!
You could try javascript redirect instead of Header command. Like
echo "<script>window.location.href = '$url'</script>";
But this will not work if javascript is disabled in the browser (Google Analytics will not track click either in this case)