frankmill Posted June 20, 2012 Report Share Posted June 20, 2012 Hello All, I am testing 3 pages, and have found a script to rotate between the 3 pages. These are the pages people see after they have opted into a squeeze page. What I would like to do is record in a text file how many times each thank-you page has been "hit". This is the script I have: <? //enter your affiliate urls below, you can enter as many as you want, please //make sure that you have the affiliate url with the SUBID syntax at the end //of it, for reference goto: subids.com for more information. $offer[1] = 'http://urlthankyou1.html'; $offer[2] = 'http://urlthankyou2.html'; $offer[3] = 'http://urlthankyou3.html'; //this is the text file, which will be stored in the same directory as this file, //count.txt needs to be CHMOD to 777, full privlledges, to read and write to it. $myFile = "count.txt"; //open the txt file $fh = @fopen($myFile, 'r'); $offerNumber = @fread($fh, 5); @fclose($fh); //see which landing page is next in line to be shown. if ($offerNumber >= count($offer)) { $offerNumber = 1; } else { $offerNumber = $offerNumber + 1; } //write to the txt file. $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $offerNumber . "\n"; fwrite($fh, $stringData); fclose($fh); //redirect to the affilate url, + add the subid at the end header('location: ' .$offer[$offerNumber]); ?> At the moment it just records the last offer number it seems. What do I need to do to get it to record the actual number of times each offer is viewed? Is there a way of also getting it to record the number of times the offer is uniquely viewed? Thanks for any help. Hopefully this is an easy one for you guys - I think the "write to the txt file" part of the script needs to be altered, but my php is a little rusty! Regards Frank Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 21, 2012 Report Share Posted June 21, 2012 Perhaps it would make sense to use Google analytics for keeping track of the analytics portion of this? I think that would be a much more cost-effective option, since you wouldn't have to write everything yourself and it would take care of tracking page views/unique page views. Quote Link to comment Share on other sites More sharing options...
frankmill Posted June 26, 2012 Author Report Share Posted June 26, 2012 Perhaps it would make sense to use Google analytics for keeping track of the analytics portion of this? I think that would be a much more cost-effective option, since you wouldn't have to write everything yourself and it would take care of tracking page views/unique page views. Thanks Ben - I have done just that. Don't know why I didn't think of this before! However - just in the interest of not being too dependant on Google, and also of just knowing how to do it - isn't there a simple way of adjusting this code? Frank Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.