Forum Moderators: skibum

Message Too Old, No Replies

CJ.com jump script/ tracking script

CJ.com, jump script, tracking script, analytics

         

trnsfrmr

12:53 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



Hi,

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!

trnsfrmr

4:06 pm on Apr 18, 2007 (gmt 0)

10+ Year Member



Or instead of working with my dodgy code, perhaps someone could point to to an existing jump/ tracking PHP script for CJ.com?

I did try and search for such a thing but got nothing. But I'm sure others must have tried this before now...

joelgreen

10:59 am on Apr 26, 2007 (gmt 0)

10+ Year Member



The problem is all header commands should be sent before the page content. You have header command at the end. I believe this would crash on most servers. But looks like server can be setup to cache page and send headers first (like in your case).

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)

trnsfrmr

12:51 pm on Apr 26, 2007 (gmt 0)

10+ Year Member



Thanks!