With the addition of channels it's now really easy to work out which ads perform best on your site by getting specific CTR and CPC rates. I've posted a very simple PHP script on my blog explaining what to do which may be useful to any non scripting people.
I've been trying to integrate this script into my archive but so far no luck - the ads don't display. All I see is < ?php $lAdvertKeyword = GetRandomChitikaAd(); ?> Code (markup): where the ad should be. Any ideas to get this working? What is the correct formatting for the textfile?
Oh.. and looks like the code splits on return+newline, so one keyword per line. (and make it in a non-unix editor) Nice idea btw.
I had trouble getting the code to display in WP so I'll post it here too function GetRandomChitikaAd() { $lFilename = "chitikakeywords.txt"; $lFullPath = get_option('siteurl') . "/" . $lFilename; $lFileContents = file_get_contents($lFullPath); $lWordArray = preg_split('/[\n\r]+/',$lFileContents ); $lRandomPhrase = $lWordArray[rand(0, sizeof($lWordArray) - 1)]; return($lRandomPhrase); } PHP: <script type="text/javascript"><!-- ch_client = "gadgets"; ch_width = 336; ch_height = 160; ch_sid = 'ga-index-<?php echo $lAdvertKeyword; ?>'; ch_color_border = "#FFFFFF"; ch_color_bg = "#FFFFFF"; ch_color_title = "993C0F"; ch_color_text = "#000000"; ch_non_contextual = 1; ch_query = '<?php echo $lAdvertKeyword; ?>';//--> </script> <script src="http://scripts.chitika.net/eminimalls/mm.js" type="text/javascript"> </script> Code (html4strict): I have the function GetRandomChitikaAd in its own php file and then just include that in which ever file needs it.
No quotes. dct pulls in one random keyword from the file and it's used like this: ch_query = '<?php echo $lAdvertKeyword; ?>' so that takes care of any quoting.
I've added a very quick and dirty sample download to the page that demonstrates the idea without WordPresses crappy source formating.