INCLUDE_DATA

Chitika Facebook App PHP Display Function

Posted on July 12th, 2007 in Ambglb Scripts, Facebook API, PPC-Affiliates by jason

Ok since im so big on Chitika being the best option for Facebook apps, im going to share with you all the display function i wrote. This function allow you to serve multiple ads across multiple pages with unique keywords and tracking id’s using just one base include file. all you do is fill in a few vars and everything else including the fbml(facebook markup language/facebooks version of html) to create and size the iframe. Of course it is in PHP so you need PHP support on your server. Ok here we go:

first up is the file named “chitika.php”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
//change $yourid$ to your chitika id in the java script below
$w=$_GET[w];
$h=$_GET[h];
$type=$_GET[type];
$bg=$_GET[bg];
$border=$_GET[border];
$title=$_GET[title];
$text=$_GET[text];
$font=$_GET[font];
$cat=$_GET[cat];
$key=stripslashes($_GET[key]);
$sid=$_GET[sid];
$key=str_replace(',' , '","' ,$key);
?>
 
<script type="text/javascript"><!--
ch_client = "$yourid$";
ch_type = "<?php echo $type ?>";
ch_width = <?php echo $w ?>;
ch_height = <?php echo $h ?>;
ch_color_border = "<?php echo $border ?>";
ch_color_bg = "<?php echo $bg ?>";
ch_color_title = "<?php echo $title ?>";
ch_color_text = "<?php echo $text ?>";
ch_non_contextual = 1;
ch_default_category = "<?php echo $cat ?>";
ch_font_title = "<?php echo $font ?>";
ch_font_text = "<?php echo $font ?>";
ch_sid = "<?php echo $sid ?>";
var ch_queries = new Array("<?php echo $key ?>");
var ch_selected=Math.floor((Math.random()*ch_queries.length));
if ( ch_selected < ch_queries.length ) {
ch_query = ch_queries[ch_selected];
}
//--></script>
<script  src="http://scripts.chitika.net/eminimalls/mm.js" type="text/javascript">
</script>

make sure you change the “$yourid$” your chitka id, now upload the chitika.php file to your server.

up next is the actual create_chitika function, you can either add this to your apps current function include, create a function.php to include or just add it to a single page. Make sure you change the iframe src from yourdomain.com, to your domain.

1
2
3
4
5
6
7
8
9
//change the iframe src to the url of your chitika.php file
function create_chitika($w,$h,$type,$bg,$border,$title,$text,$font,$cat,$key,$sid){
$bg=str_replace("#","",$bg);
$border=str_replace("#","",$border);
$title=str_replace("#","",$title);
$text=str_replace("#","",$text);
//echo $key;
echo "<fb:iframe src=\"http://www.yourdomain.com/dirname/chitika.php?w=$w&h=$h&type=$type&bg=$bg&border=$border&title=$title&text=$text&font=$font&cat=$cat&key=$key&sid=$sid\" width=\"$w\" height=\"$h\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" frameborder=\"no\" smartsize=\"false\" />";
}

ok no need to really pay attention to that, its basically just taking the data we are about to pass to it, creates the fb iframe and chitika eminimall. ok we are done with the boring stuff and on to the actually inserting the ad on your page.

<?php create_chitika('468','180' ,'mpu' , 'ffffff', 'ff0000' ,'000000', '0000ff' ,'comic sans', '200001', 'iphones,palm treo, palm tx,ipod','facebook_appname' ); ?>

lol dont worry im going to explain how this all works, what that code chunk did was create a 468×180 multi product banner, with a white background and red border, black title, blue text, comic sans font, category 200001, for the products iphones,palm treo
palm tx,ipod all reporting under the facebook_appname tracking channel.

1
<?php create_chitika('width','height' ,'type' , 'background', 'border' ,'title', 'text' ,'font', 'category', 'keyword 1,keyword 2, keyword 3','tracking channel name' ); ?>

ok i made this one easier to understand, below i have broke down what each var is
width== the width of the ad to be displayed
height==the height of the ad to be displayed
type==the type of ad set to mpu for multi product banner or leave empty for normal ads
background== the background color of the ad ie ffffff
border==the color of the ads border ie ffffff
title==the color of the ad title ie ffffff
text==the color of the description text ie ffffff
font==the font style of the ad ie arial
category==the chitika category id number ie 89
keywords== a comma seperated list of keywords you want ads to show for ie ipods
tracking channel name==the tracking name you want the ad to be tracked under in your chitika reports panel

you can also use varibles within the function by leaving off the ‘ ‘ on the var so

1
2
3
4
<?php 
$keywords="keyword 1,keyword 2,keyword 3";
create_chitika('468','180' ,'mpu' , 'ffffff', 'ff0000' ,'000000', '0000ff' ,'comic sans', '200001', $keywords,'facebook_appname' ); 
?>

So now you are armed with the ability to target ads to a user’s profile information, if you are having problems copying and pasting the code you can download the chitika.php and function.php pages below. Next time i’ll show you how to parse a user’s hobbies and intrests into a chitika ad.

Download Chitika Facebook App PHP Display Function Files

Adsense OK With Facebook Apps

Posted on July 12th, 2007 in Facebook API, PPC-Affiliates by jason

Well i was wrong (not the first time i know lol). After debating for a while i decided to email Adsense support to find out if Facebook apps violated the TOS or not. To my surprise the reply i got, gave the go ahead.(btw i received a reply in less than 24 hours).
“…webpage complies with our policies and you’re able to edit the source code of the site to allow javascript, then you’re welcome to place Google ads on your site…”

Pretty cool i must say, so of course i went right to some of my apps to add in some code to see how it would work. As you know we have some fairly popular sites, and our apps are “stored” under one of those domains, so of course at first i got ads themed towards the main domain. No biggie i was thinking that referrals would be a better match anyway, so i created a few and after almost 3 years as an Adsense publisher i know it takes ole googlebot a few page views by a different users to get a grasp on a page, i stuck up some adlinks. Within a day or so the adlinks were themed to facebook,(also the name of the directory they were in). so i added the ad units back in, and low and behold i was getting blocks themed towards facebook. These were just called into the canvas page via the fb iframe method, the page itself wasn’t an iframe. So remember your directory and url structure is going to be important. I have also implemented some tests on pages that are complete iframes with pretty good results as well so far, not as great targeting as a “regular” webpage would have but still pretty good. Though if you want to advertise special products i still think Chitika
and their manually targeting option is the better choice, but nothing wrong with running them both. I’m in the process of putting together a top 5 or 10 Adsense for Facebook tips, ill be posting in the next day or two so keep your eyes open.