Adsense/YPN Conflict

In this example, we automatically scan web pages and report if any page displays conflicting Adsense and YPN ads.

According to the TOS (Terms of Service) of both Google Adsense and the Yahoo! Publisher Network (YPN), on any web page, you may display ads for one program or the other but not both simultaneously.  If your CMS (Content Management System) or your hand editing of web pages has mistakenly placed ads for both on the same page, you have committed a TOS violation, which might earn you expulsion from one or both programs.  Naturally, you would want to be alerted to the TOS violation before that happens.

The AdsenseYPNConflict script might send an alert message like the following:

                                PIKT ALERT
                         Wed Dec  7 06:38:25 2005
                                 calgary

WARNING:
    AdsenseYPNConflict
        Report if we have both Adsense and YPN on the same page

        /var/www/html/pikt/authors.html:  adsense/ypn conflict
        [...]

The script follows.

#if piktwebsys

AdsenseYPNConflict

        init
                status =piktstatus
                level =piktlevel
                task "Report if we have both Adsense and YPN on the same page"

#ifdef debug
                input proc "=find =piktwebdir -name \\*.html -print
                            -exec =egrep -ic '\\<body\\>' {} \\;
                            -exec =egrep -ic '\\<body\\>' {} \\;"
#elsedef
                input proc "=find =piktwebdir -name \\*.html -print
                            -exec =egrep -c pagead2\\.googlesyndication\\.com {} \\;
                            -exec =egrep -c ypn-js\\.overture\\.com {} \\;"
#endifdef

        rule
                if $inlin =~ "^=piktwebdir"
                        set $page = $inlin
#ifdef debug
                        output $page
#endifdef
                        next
                endif

#ifdef debug
        rule
                output $inlin
#endifdef

        rule
                if    #val($inlin) > 0
                   && #val(@inlin) > 0
                        output mail "$page: adsense/ypn conflict"
                endif

#endif  // piktwebsys

The "input proc" statement

                input proc "=find =piktwebdir -name \\*.html -print
                            -exec =egrep -c pagead2\\.googlesyndication\\.com {} \\;
                            -exec =egrep -c ypn-js\\.overture\\.com {} \\;"

would output a series of lines like

/var/www/html/pikt/authors.html
2
1
/var/www/html/pikt/licensing.html
1
0
[...]

In the final script rule, we test to see if the both the current line ($inlin) and the previous line (@inlin) are greater than zero.  If so, the page is displaying both Adsense and YPN ads.

Note that if the "debug" define is set, for example, we have installed the script with the command

piktc -iv +D test debug +A Test +H calgary

the script would instead have the "input proc" statement

                input proc "=find =piktwebdir -name \\*.html -print
                            -exec =egrep -ic '\\<body\\>' {} \\;
                            -exec =egrep -ic '\\<body\\>' {} \\;"

Since every web page should have one (and only one) "<body>" tag, we should see successive 1s for every page, not 0s or some other number, thereby forcing the "$page: adsense/ypn conflict" output.

If you are running some other ad program (Chitika, AdBrite, etc.), you could modify the script appropriately.

This is just one program example.  You could write new scripts to:  check the value of other fields in the Adsense JavaScript code (example); make sure that you have not violated the Adsense rules about total ad units (example); check the validity of any Adsense section targeting tags (example); and so on.

For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
HTML
font size
macros