1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Finding out the CPC of all your ads

Discussion in 'Chitika' started by dct, Nov 8, 2005.

  1. #1
    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.
     
    dct, Nov 8, 2005 IP
    solution2u likes this.
  2. The Sandman

    The Sandman Well-Known Member

    Messages:
    95
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    143
    #2
    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?
     
    The Sandman, Nov 8, 2005 IP
  3. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You have a blank space between "<" and "?php" ?
     
    blinxdk, Nov 8, 2005 IP
  4. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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.
     
    blinxdk, Nov 8, 2005 IP
  5. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #5
    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.
     
    dct, Nov 8, 2005 IP
  6. The Sandman

    The Sandman Well-Known Member

    Messages:
    95
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    143
    #6
    One keyword per line? Any single or double quotes?
     
    The Sandman, Nov 8, 2005 IP
  7. solution2u

    solution2u Peon

    Messages:
    252
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nice code. Good idea.
     
    solution2u, Nov 8, 2005 IP
  8. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #8
    Yeah one per line and it doesn't cope with quotes at all. I'm putting a quick download together now,
     
    dct, Nov 8, 2005 IP
  9. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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.
     
    blinxdk, Nov 8, 2005 IP
  10. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #10
    I've added a very quick and dirty sample download to the page that demonstrates the idea without WordPresses crappy source formating.
     
    dct, Nov 8, 2005 IP
  11. The Sandman

    The Sandman Well-Known Member

    Messages:
    95
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    143
    #11
    I just can't get this to work. Where did you say the download was - I don't see it...
     
    The Sandman, Nov 8, 2005 IP
  12. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #12
    There was a link at the bottom of the page or from here
     
    dct, Nov 8, 2005 IP