Hi PHPers, I am trying to setup an automatice tracking script for my product. What I would like to setup is this: http://fatloss4idiots.com/aff/tracking.html Basically, rather than me putting a different conversion script on my order confirmation page for every affiliate - I want to put ONE script on the page that puts in conversion ID for each affiliate automatically. So at the end of the affiliates link they would put "&gid=93939393939393". The gid is then put on the conversion page automatically.. When ever I go the the sales page I get this error: Warning: Division by zero in /home/xxxxxx/public_html/salespage.php on line 6 Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/public_html/salespage.php:6) in /home/xxxxxx/public_html/salespage.php on line 6 Code (markup): I could be completely wrong? Anybody think they can work this one out?
<?php $gid = $_GET['gid']; if ($gid == ''){ if(isset($_COOKIE['gid'])){ $gid = $_COOKIE['gid']; }else{ Echo "No cookie or Gid set"; } }else{ setcookie('gid',$gid,time()+2592000,'/'); } ?> PHP: Try that, I added some more brackets for better readability and removed the unnecessary calculation to save php from having to do it. I tested it and it works fine for me, the problem was with your quotes, I don't know what they're called but they're not standard double " or single ' quotes and php didn't seem to recognise them. I also added a condition to check if there is a post variable with gid set.
Hey mate. I think its working.. If I go: www.mydomain.com/page.php?gid=9999999999 it puts the gid correctly on the conversion page.. However. From the affiliate link it goes to a php page that then sends visitors to different pages depending on the landing page selected. So the affiliate link: http://d2c8s5.earth4.hop.clickbank.net/ Then goes to a PHP page with the following code: <?php if ($_GET['lp'] == 'windpower') { header('Location: http://www.earth4energy.com/windpower.html'); exit(); } if ($_GET['lp'] == 'windgenerator') { header('Location: http://www.earth4energy.com/windgenerator.html'); exit(); } if ($_GET['lp'] == 'renewableenergy') { header('Location: http://www.earth4energy.com/renewableenergy.html'); exit(); } if ($_GET['lp'] == 'windelectricity') else { header('Location: http://www.earth4energy.com'); exit(); } ?> Code (markup): This is so affiliate can ad "&lp=xxxxxxxx" so send visitors to different pages. So when the code you supplied above is added to the sales page I dont think the the gid gets passed onto it. It seems possible to do the auto tracking in combination with different landing pages but I cant seems to pass the GID on from the affiliate link to the sales page. I have added your code above to target affiliate link where the visitor is directed to the sales page however I get this error: Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxx/public_html/websitename/1/index.php:10) in /home/xxxxx/public_html/websitename/1/index.php on line 37 Code (markup): Thanks heaps for the help so far. I think if i wasnt using different sales pages and the affiliate link went straight to the page with the code it would work. Any idea how to combine the multi pages + auto tracking? Thanks again!
Yep.. here is the url: http://www.earth4energy.com/solarpower3.php?gid=oooooooo It adds oooooooo as the GID on the conversion page when i go to the above url But using the affiliate link of: http://xxxxx.earth4.hop.clickbank.net?lp=solarpower3&gid=iiiiiiiiiiii << doesnt work Thanks again
I should have been more specific. I meant the php code for the page. It is easier to work out a problem when you can see the whole picture. You can remove any unnecessary html though.
Thi sis the current order: Affiliate link: http://xxxxx.earth4.hop.clickbank.net?lp=solarpower3&gid=kkkkkkkk The visitor then goes to a page with the following code: <?php if ($_GET['lp'] == 'windpower') { header('Location: http://www.earth4energy.com/windpower.html'); exit(); } if ($_GET['lp'] == 'windgenerator') { header('Location: http://www.earth4energy.com/windgenerator.html'); exit(); } if ($_GET['lp'] == 'renewableenergy') { header('Location: http://www.earth4energy.com/renewableenergy.html'); exit(); } if ($_GET['lp'] == 'windelectricity') { header('Location: http://www.earth4energy.com/windelectricity.html'); exit(); } if ($_GET['lp'] == 'solarpower3') { header('Location: http://www.earth4energy.com/solarpower3.php'); exit(); } ETC.... else { header('Location: http://www.earth4energy.com'); exit(); } ?> Code (markup): The visitor then goes the the page that LP sets. In my example the LP is: solarpower3 The solarpower3 page has the following code: <?php $gid = $_GET['gid']; if ($gid == ''){ $gid = $_COOKIE['gid']; }else{ setcookie('gid',$gid,time()+2592000,'/'); } ?> Code (markup): After a conversion is made they go to the conversion page with the following code: <script language="JavaScript" type="text/javascript"> <!-- var google_conversion_id = <?php echo $gid; ?>; var google_conversion_language = "en"; var google_conversion_format = "1"; var google_conversion_color = "ffffff"; var google_conversion_label = "purchase"; //--> </script> <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/<?php echo $gid; ?>/?label=purchase&script=0"/> </noscript> Code (markup): The problem is: The GID doesnt pass from the affiliate link to the solarpower3 page because of the page that directs the visitor depending on the LP. Hope this helps Thanks again.
<?php $gid = $_GET['gid']; if ($_GET['lp'] == 'windpower') { header('Location: http://www.earth4energy.com/windpower.html'); exit(); } if ($_GET['lp'] == 'windgenerator') { header('Location: http://www.earth4energy.com/windgenerator.html'); exit(); } if ($_GET['lp'] == 'renewableenergy') { header('Location: http://www.earth4energy.com/renewableenergy.html'); exit(); } if ($_GET['lp'] == 'windelectricity') { header('Location: http://www.earth4energy.com/windelectricity.html'); exit(); } if ($_GET['lp'] == 'solarpower3') { header("Location: http://www.earth4energy.com/solarpower3.php?gid=$gid"); exit(); } ETC.... else { header('Location: http://www.earth4energy.com'); exit(); } ?> PHP: I guess it is because your not passing the gid in the url during the redirect so you can just do as I have done above. Note that I used double quotes because php does not check for variables in single quotes.