View Full Version : Finding out the CPC of all your ads
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 (http://www.sagecroft.co.uk/2005/11/08/finding-out-the-cpc-for-chitika-ads/) explaining what to do which may be useful to any non scripting people.
The Sandman
Nov 8th 2005, 6:16 am
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(); ?>where the ad should be. Any ideas to get this working? What is the correct formatting for the textfile?
blinxdk
Nov 8th 2005, 6:46 am
You have a blank space between "<" and "?php" ?
blinxdk
Nov 8th 2005, 6:47 am
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);
}
<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>
I have the function GetRandomChitikaAd in its own php file and then just include that in which ever file needs it.
The Sandman
Nov 8th 2005, 6:55 am
Oh.. and looks like the code splits on return+newline, so one keyword per line. (and make it in a non-unix editor)One keyword per line? Any single or double quotes?
solution2u
Nov 8th 2005, 6:56 am
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);
}
<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>
I have the function GetRandomChitikaAd in its own php file and then just include that in which ever file needs it.
Nice code. Good idea.
Yeah one per line and it doesn't cope with quotes at all. I'm putting a quick download together now,
blinxdk
Nov 8th 2005, 6:58 am
One keyword per line? Any single or double quotes?
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 (http://www.sagecroft.co.uk/2005/11/08/finding-out-the-cpc-for-chitika-ads/) that demonstrates the idea without WordPresses crappy source formating.
The Sandman
Nov 8th 2005, 8:50 am
I've added a very quick and dirty sample download to the page (http://www.sagecroft.co.uk/2005/11/08/finding-out-the-cpc-for-chitika-ads/) that demonstrates the idea without WordPresses crappy source formating.I just can't get this to work. Where did you say the download was - I don't see it...
There was a link at the bottom of the page or from here (http://www.sagecroft.co.uk/downloads/chitikasamplepage.zip)
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.