tracking202 + website optimizer

dewme5

New member
Dec 30, 2008
194
1
0
I was having a little problem with getting tracking setup. After fumbling thru some java, and the tracking202 forum, I thought I would post the success portion. Credit does go over to tracking202 though.

If you go thru tracking202 or prosper202, you are give some php code that allows tracking of whose clicking thru from your LP to the actual product page.

An example would be.

Code:
<?php
  
  // ------------------------------------------------------------------- 
  //
  // Tracking202 PHP Redirection, created on Thu Jul, 2009
  //
  // This PHP code is to be used for the following landing page.             
  // http://cashfromthekeyboard.com/google
  //                       
  // -------------------------------------------------------------------
  
  if (isset($_COOKIE['tracking202outbound'])) {
    $tracking202outbound = $_COOKIE['tracking202outbound'];     
  } else {
    $tracking202outbound = 'http://yourstuffhere';   
  }
  
  header('location: '.$tracking202outbound);
  
?>
Ultimately, there are several things in here that will change, but that is the code the tracking202 provides.

Google provides the following code, which is supposed to go just prior to the </body> tag.
Code:
 <script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var pageTracker=_gat._getTracker("UA-*******-1");
pageTracker._trackPageview("/**********/goal");
}catch(err){}</script>
Unfortunately, this did not work for me. Since it was a php page, I had no body tags, and it also output some error code.

I started looking around, and came across the T202 solution, which didn't work right away either. I could get google to validate, but the page would not load. Or, I could load the page, and google would throw an error. After several iteration, this was the final working solution.

As main.php this did not work. as main.html, it did.



Final page code
Code:
 <script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var pageTracker=_gat._getTracker("UA-*******-1");
pageTracker._trackPageview("/*********/goal");
}catch(err){}</script>


<!-- This is the thankyou/redirect.html page-->

<!-- PLACE GOOGLE THANK YOU PIXEL CODE HERE -->

<!-- NOW THE TRACKING202 REDIRECTS OUT -->

<script type="text/javascript">

window.location='http://Your site here with t202 info' + ReadCookie('tracking202pci');

function ReadCookie(n) {

var cookiecontent = new String();

if(document.cookie.length > 0) {

var cookiename = n+ '=';

var cookiebegin = document.cookie.indexOf(cookiename);

var cookieend = 0;

if(cookiebegin > -1) {

cookiebegin += cookiename.length;

cookieend = document.cookie.indexOf(";",cookiebegin);

if(cookieend < cookiebegin) { cookieend = document.cookie.length; }

cookiecontent = document.cookie.substring(cookiebegin,cookieend);

}

}

return unescape(cookiecontent);

} // function ReadCookie()
</script>
Basically, it's totally different now. went from PHP to javascript. As far as I can tell, this is working correctly for me.