[Solved]: Targeting adsense ads to album name [Solved]: Targeting adsense ads to album name
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: Targeting adsense ads to album name

Started by vishnu, February 12, 2009, 05:28:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vishnu

Hi,

The adsense ads I get in my gallery are not optimized. I read some other posts in the forum related to adsense optimization and tried some of them. I want to target my ads to the album name. I can use the <!-- google_ad_section_start --> <!-- google_ad_section_end --> tags to target a specific area in the site. But where should I add this so that the target are will be th name of my album?

Thank you


vishnu

#2
Sorry, I didn't paste the link since I thought this is a general question. Here's the link to my gallery

http://www.autoracingdaily.net [Edit GauGau] Warning: link not safe for work (contains mild nudity) [/edit]

--vishnu

Joachim Müller

OK, I get the point. However, you haven't implemented your adsense properly: the attached screenshot shows that the added table cell causes mis-alignement. You appear to have fiddled with the table cell nesting.
I suggest you zip your custom file theme.php and attach it to your reply.

vishnu

I've attached the archived theme.php along with this. Please consider my original question too (optimizing adsense for Album name).

Joachim Müller

Quote from: vishnu on February 12, 2009, 05:28:10 AM
I can use the <!-- google_ad_section_start --> <!-- google_ad_section_end --> tags to target a specific area in the site.
You are wrong in this aspect - I read this tag up on the google adsense help pages: that tag is meant to narrow down the actual textual content of your site. I have wrapped the {GALLERY}-token in template.html into thos tags, but this will not give you the desired result. Google adsense does take your album name into account already. What you're trying to do is actually giving it more weight or importance. You can do that with regular HTML methods, as the tag needs to be more important in SEO terms. You can accomplish this by wrapping the album name into header tags (<h1> to <h6>). There are several postings that explain how to accomplish this.
What I actually did was fixing your improper nesting issues that resulted in distorted pages. As you have based your custom theme on fiapple by daMysterious I have downloaded that theme and renamed it accordingly. You should do the same thing, i.e. unzip the attachment into your themes folder and then visit your gallery with the new theme forced for you only by entering the URL http://www.autoracingdaily.net/?theme=autoracingdaily into your browser's address bar. After reviewing you can permanently make the new theme the default using Coppermine's config.
Please note the switch //define('DISPLAY_ADS_FOR_META_ALBUMS', 1); // Uncomment to enable ads for meta albumsin theme.php that I added: uncomment to display google ads for meta albums as well, i.e. change todefine('DISPLAY_ADS_FOR_META_ALBUMS', 1); // Uncomment to enable ads for meta albums
I reviewed your theme closely and removed all the surplus stuff that is not needed (because it doesn't differ from default behaviour).
For those who are interessted in the same thing, here are the relevant sections of theme.php:<?php
//define('DISPLAY_ADS_FOR_META_ALBUMS', 1); // Uncomment to enable ads for meta albums
// HTML template for thumbnails display
$template_thumbnail_view = <<<EOT

<!-- BEGIN header -->
        <tr>
<!-- END header -->
<!-- BEGIN thumb_cell -->
        <td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
                <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                                <td align="center">
                                        <a href="{LINK_TGT}">{THUMB}<br /></a>
                                        {CAPTION}
                                        {ADMIN_MENU}
                                </td>
                        </tr>
                </table>
        </td>
<!-- END thumb_cell -->
<!-- BEGIN empty_cell -->
                <td valign="top" class="<!--thumbnails-->" align="center">&nbsp;</td>
<!-- END empty_cell -->
<!-- BEGIN row_separator -->
        </tr>
        <tr>
<!-- END row_separator -->
<!-- BEGIN footer -->
        </tr>
<!-- END footer -->
<!-- BEGIN tabs -->
        <tr>
                <td colspan="{THUMB_COLS}" style="padding: 0px;">
                        <table width="100%" cellspacing="0" cellpadding="0">
                                <tr>
                                       {TABS}
                                </tr>
                        </table>
                </td>
        </tr>
<!-- END tabs -->
<!-- BEGIN spacer -->
        <img src="images/spacer.gif" width="1" height="7" border="" alt="" /><br />
<!-- END spacer -->
<!-- BEGIN advert -->
        <td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
                <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                                <td align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-8201897207053754";

/* 125x125, created 10/13/08 */

google_ad_slot = "2020184940";

google_ad_width = 125;

google_ad_height = 125;
google_color_border = "666666";
google_color_bg = "F1F1F1";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//-->

</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
                                </td>
                        </tr>
                </table>
        </td>
<!-- END advert -->

EOT;


function 
theme_display_thumbnails(&$thumb_list$nbThumb$album_name$aid$cat$page$total_pages$sort_options$display_tabs$mode 'thumb')

{

    global 
$CONFIG;

    global 
$template_thumb_view_title_row,$template_fav_thumb_view_title_row$lang_thumb_view$template_tab_display$template_thumbnail_view$lang_album_list;



    static 
$header '';

    static 
$thumb_cell '';

    static 
$empty_cell '';

    static 
$row_separator '';

    static 
$footer '';

    static 
$tabs '';

    static 
$spacer '';
    static 
$advert '';



    if (
$header == '') {

        
$thumb_cell template_extract_block($template_thumbnail_view'thumb_cell');

        
$tabs template_extract_block($template_thumbnail_view'tabs');

        
$header template_extract_block($template_thumbnail_view'header');

        
$empty_cell template_extract_block($template_thumbnail_view'empty_cell');

        
$row_separator template_extract_block($template_thumbnail_view'row_separator');

        
$footer template_extract_block($template_thumbnail_view'footer');

        
$spacer template_extract_block($template_thumbnail_view'spacer');
        
$advert template_extract_block($template_thumbnail_view'advert');

    }



    
$cat_link is_numeric($aid) ? '' '&amp;cat=' $cat;

    
$uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' $_GET['uid'] : '';



    
$theme_thumb_tab_tmpl $template_tab_display;



    if (
$mode == 'thumb') {

        
$theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $aid == 'lastalb' $lang_album_list['album_on_page'] : $lang_thumb_view['pic_on_page']));

        
$theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'thumbnails.php?album=' $aid $cat_link $uid_link '&amp;page=%d'));

        
$theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'thumbnails.php?album=' $aid $cat_link $uid_link '&amp;page=%d'));

        
$theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'thumbnails.php?album=' $aid $cat_link $uid_link '&amp;page=%d'));

    } else {

        
$theme_thumb_tab_tmpl['left_text'] = strtr($theme_thumb_tab_tmpl['left_text'], array('{LEFT_TEXT}' => $lang_thumb_view['user_on_page']));

        
$theme_thumb_tab_tmpl['inactive_tab'] = strtr($theme_thumb_tab_tmpl['inactive_tab'], array('{LINK}' => 'index.php?cat=' $cat '&amp;page=%d'));

        
$theme_thumb_tab_tmpl['inactive_next_tab'] = strtr($theme_thumb_tab_tmpl['inactive_next_tab'], array('{LINK}' => 'index.php?cat=' $cat '&amp;page=%d'));

        
$theme_thumb_tab_tmpl['inactive_prev_tab'] = strtr($theme_thumb_tab_tmpl['inactive_prev_tab'], array('{LINK}' => 'index.php?cat=' $cat '&amp;page=%d'));

    }



    
$thumbcols $CONFIG['thumbcols'];
    
$thumbrows $CONFIG['thumbrows'];

    
$cell_width ceil(100 $CONFIG['thumbcols']) . '%';



    
$tabs_html $display_tabs create_tabs($nbThumb$page$total_pages$theme_thumb_tab_tmpl) : '';

    
// The sort order options are not available for meta albums

    
if ($sort_options) {

        
$param = array('{ALBUM_NAME}' => $album_name,

            
'{AID}' => $aid,

            
'{PAGE}' => $page,

            
'{NAME}' => $lang_thumb_view['name'],

            
'{TITLE}' => $lang_thumb_view['title'],

            
'{DATE}' => $lang_thumb_view['date'],

            
'{SORT_TA}' => $lang_thumb_view['sort_ta'],

            
'{SORT_TD}' => $lang_thumb_view['sort_td'],

            
'{SORT_NA}' => $lang_thumb_view['sort_na'],

            
'{SORT_ND}' => $lang_thumb_view['sort_nd'],

            
'{SORT_DA}' => $lang_thumb_view['sort_da'],

            
'{SORT_DD}' => $lang_thumb_view['sort_dd'],

            
'{POSITION}' => $lang_thumb_view['position'],

            
'{SORT_PA}' => $lang_thumb_view['sort_pa'],

            
'{SORT_PD}' => $lang_thumb_view['sort_pd'],

            );

        
$title template_eval($template_thumb_view_title_row$param);

    } else if (
$aid == 'favpics' && $CONFIG['enable_zipdownload'] == 1) { //Lots of stuff can be added here later

       
$param = array('{ALBUM_NAME}' => $album_name,

                             
'{DOWNLOAD_ZIP}'=>$lang_thumb_view['download_zip']

                               );

       
$title template_eval($template_fav_thumb_view_title_row$param);

    }else{

        
$title $album_name;

    }





    if (
$mode == 'thumb') {

        
starttable('100%'$title$thumbcols);

    } else {

        
starttable('100%');

    }



    echo 
$header;



    
$i 0;

    
// Start modification "random table cell ad"
    
$number_of_thumbs count($thumb_list);
    
$advert_position rand(0,$number_of_thumbs-1);
    foreach(
$thumb_list as $thumb) {

        
$i++;

        if (
$mode == 'thumb') {

            if (
$aid == 'lastalb') {

                
$params = array('{CELL_WIDTH}' => $cell_width,

                    
'{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",

                    
'{THUMB}' => $thumb['image'],

                    
'{CAPTION}' => $thumb['caption'],

                    
'{ADMIN_MENU}' => $thumb['admin_menu']

                    );

            } else {

                
$params = array('{CELL_WIDTH}' => $cell_width,

                    
'{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}$uid_link",

                    
'{THUMB}' => $thumb['image'],

                    
'{CAPTION}' => $thumb['caption'],

                    
'{ADMIN_MENU}' => $thumb['admin_menu']

                    );

            }

        } else {

            
$params = array('{CELL_WIDTH}' => $cell_width,

                
'{LINK_TGT}' => "index.php?cat={$thumb['cat']}",

                
'{THUMB}' => $thumb['image'],

                
'{CAPTION}' => $thumb['caption'],

                
'{ADMIN_MENU}' => ''

                
);

        }
        
// Add the advert cell 
        
if (defined('DISPLAY_ADS_FOR_META_ALBUMS') || is_numeric($aid) == TRUE) {
        
$display_advert 1;
        } else {
        
$display_advert 0;
        }
        if (
$i == $advert_position && $mode == 'thumb' && $display_advert == 1) {
        if ($number_of_thumbs $thumbcols $thumbrows) { // We have room to display the extra advert cell
         //print_r($thumb_list);
         $thumb_list[($number_of_thumbs+1)] = $thumb;
         echo template_eval($advert$params);
    } else { // We do not have room for the extra advert cell, so we'll have to replace one (i.e. drop the content of the thumb that should usually reside here without the ad)
     echo template_eval($advert$params);
    }
        } else {
        
echo template_eval($thumb_cell$params);
        }



        if (((
$i $thumbcols) == 0) && ($i count($thumb_list))) {

            echo 
$row_separator;

        }

    }

    for (;(
$i $thumbcols); $i++) {

        echo 
$empty_cell;

    }

    echo 
$footer;



    if (
$display_tabs) {

        
$params = array('{THUMB_COLS}' => $thumbcols,

            
'{TABS}' => $tabs_html

            
);

        echo 
template_eval($tabs$params);

    }



    
endtable();

    echo 
$spacer;

}
?>

vishnu

Hi Joachim,

Thank you for the detailed reply and all your help. I made the changes and everything seems fine now.

Regards,
Vishnu