Forum Moderators: martinibuster
If you have a site that has, say, 8 or 9 subject pages (news, reviews, etc) that you use channels for adsense tracking, how can you incorporate the ads when using a SSI for a left bar, for example?
Another way to put it is, I have a left bar on a page with links, search, graphic, etc, plus an AS skyscraper.. but I want to have it linked to the "News" channel so I can track it's progress, how can I make that work with a SSI without splitting the left bar include in half? Is it possible? Or would I have to do something like:
<include leftbar top>
adsense code
<include leftbar bottom>
for each page I wanted a channel tracked ad?
Thanks in advance.
$news = "324234234";
$tutorials = "4555445";
and so on
then make some condition, let's say the name of the category is stored in $_GET['category']
if ($_GET['category'] == "news"){
$google_ad_channel = $news;
}
and so on
finally echo the adsense code and replace the number after "=" with the variable $google_ad_channel. Remember about escaping all quotation marks with "\". The whole code might look similiar to this:
<?php
$news = "324234234";
$tutorials = "4555445";
if ($_GET['category'] == "news"){
$google_ad_channel = $news;
}
echo "<script type=\"text/javascript\"><!--
google_ad_client = \"pub-somepub\";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = \"728x15_0ads_al_s\";
google_ad_channel =\"$google_ad_channel\";
google_color_border = \"FFFFFF\";
google_color_bg = \"FFFFFF\";
google_color_link = \"993300\";
google_color_text = \"000000\";
google_color_url = \"999999\";
//--></script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>";
?>
In this way you can track many channels.
Hope it helped
Storm
You know how you use php to change the title of each new page? $title is in the include and the actual title name of the page is in the page? Well could you do something like that for the adsense code?
What I'm thinking is, you put the same kind of php code you use for the title (in the include) in the position where the adsense code would go (in the left bar, in the include). Then in the .php file where your content goes, you would have code similar to that which names your title page.. something like:
$title = "Title name here"; (something like this)
BUT, instead of 'adsense-news', you would use an include there to call the specific adsense code with the channel info for that page. Maybe something like:
<?php
$adsense = include('ads/adnews.php'); (you get the idea)
?>
So it would work in the same way of naming the title on a per page basis, but call an include which would have your specific adsense code instead. This way you aren't editing the adsense code, and for the 8 or 9 pages that I'm dealing with, if I made any changes to the channels, size of the ad, etc, I could just replace the one file with the actual adsense code and control its placement with the single line in the include. I hope this all makes sense.
I assume most people with tons of pages that use adsense don't use channels to keep track of it - or maybe just a single channel for all news related pages or a single channel for all review related pages.
Either way thank you for the responses.
Except i'm using ASP.
I define the google channel as a variable on each page of the website (gvar="7654322345") and then use an include to bring in a snippet ASP that has the adsense code and uses the variable in the channel line.
This also allows me to switch to other ad methods quickly or even use a random number generator to show one ad vs another a certain percentage of time.
Well, that's certainly an option, however, I think you should fear changing the code in the way I did it in my last post. This certainly doesn't go under "modifying code" because the output of this PHP script is just a regular javascript code. Correct me if I'm wrong.
Pulszar, try to make it all work and let know if any further questions.
Good luck
Storm
Here's the new thread: [webmasterworld.com ]
Thanks again for all the help, much appreciated.