Home arrow SEO Articles arrow JavaScript Variables Used in AdSense

JavaScript Variables Used in AdSense PDF Print E-mail

If you’re an AdSense publisher, you're probably aware that there are a number of customizations options available to you by using the AdSense for Content ad creation tool.  However, cut-and-paste html design is fine for some publishers, others may want finer control over how ads are integrated into their site.  For example, a designer might use a scripted language such as PHP to dynamically control things such as ad type, size, or colors.

fIt’s unfortunate that Google doesn’t make this list easier to find in the help and support section on their website.  Perhaps it’s because that, according to the Google AdSense Program Policy, "Any AdSense code must be pasted directly into webpages without modification,” and that, “AdSense participants are not allowed to alter any portion of the code or change the behavior, targeting, or delivery of ads.”

Still, its not like there arn't tens of thousands of websites run content management systems which automate the process (and thus avoiding the cut-and-paste method), and the mere act of creating dynamically generate pages means that writing some of this code out by hand becomes necessary.  It is highly likely that adherence to the spirit of the law holds a higher precedence than the actual letter.  Let us not forget that Google’s own motto is, “Do no evil.”

That said, we present this list of identified variables along with their descriptions, with the hopes that it makes your job a little easier.

VariableTypeDescription
google_ad_clientQuoted StringThis variable is without a doubt the most important variable in the list.  While miss-configuring the others might cause the add to appear incorrectly, a typo here can result in you not getting paid for eligible ad clicks.  The value of this variable is your AdSense Publisher ID, which can be found in the upper right hand corner of your publishers dashboard.
google_ad_slotQuoted String

For many the easiest way to create and manage ads is by using the AdSense dashboard.  When ads are created in this manner, various aspects of the ad appearance can be “pre-defined” and stored on the ad server.  When done in this fashion, using this variable will recall the saved ad settings, and use them to construct the ads appearance.

google_alternate_ad_urlQuoted StringBy using Alternate Ad URLs, publishers can control what happens in the event that the AdSense system is not able to identify a relevant advertisement.  By default, Google will fill the space with public service content (‘Hurricane Relief’ is commonly displayed).  Since clicks on public service ads generate no revenue for the content provider, it makes sense to have a backup plan.  By supplying this variable with an accompanying URL, web marketers can fill the ad space from a competing ad provider, or perhaps a filler image.

Its important to note however, that whatever content is provided must not be larger than the width and height parameters specified below; anything beyond these values will be trimmed off.

As an alternative, publishers can supply the path to a script created by Google that will cause the ad space to disappear or ‘collapse’ in these circumstances.  More information regarding Collapsing Ad Units can be found at the Google support website.

google_alternate_colorQuoted StringAs a more simple alternative to the above, a publisher can choose instead to fill the ad space with a solid color in the event that no applicable ads are available.  Like all color-related items in this list, this variable accepts a six-digit hexadecimal number, similar to those used in standard HTML markup, without the '#' symbol.
google_ad_widthIntegerSpecify the width of the JavaScript object using this variable.  It’s important to note that this has no effect on the actual ad width; this only controls the object box within which the ad unit is contained.  You may find it helpful sometimes in the event that your page layout provides an area that is wider than the ad unit itself, thus helping to insure a consistent presentation.  If the value is smaller than the ad unit however, it can cause the add to get cut off.
google_ad_heightIntegerIdentical to the variable above, however this variable controls the height of the object box.
google_ad_formatQuoted StringGoogle provides 24 different ad formats (12 ‘ad units’ and 12 ‘link units’) to fit a wide variety of spaces and placements.  Use the tables below to determine which code to use based upon the area available to you.  Note that the first part of each code indicates the width and height of the ad block.

Ad Units
Banner StyleSkyscraper StyleRectangularSquare
234x60_as
468x60_as
728x90_as

120x240_as
120x600_as
160x600_as

180x150_as
336x280_as
300x250_as
125x125_as
200x200_as
250x250_as

Ad Links
VerticalHorizontal
4-Links5-Links4-Links5-Links
728x15_0ads_al
468x15_0ads_al

728x15_0ads_al_s
468x15_0ads_al_s

120x90_0ads_al
160x90_0ads_al
180x90_0ads_al
200x90_0ads_al
120x90_0ads_al_s
160x90_0ads_al_s
180x90_0ads_al_s
200x90_0ads_al_s
  As you learn farther along in this article, displaying traditional ads isn’t the only way to generate revenue using Google AdSense.  In addition to tradtional ads, web marketers can use referral links to generate income as well.  In these situations, this variable will always be set to “ref_text”.
google_ad_typeQuoted StringBoth image ads and text ads are available to the publisher.  By default, ads of any type are displayed, however you can restrict the ads to images only or text only by supplying the variable “image” or “text” accordingly.  To explicitly define the default setting, set the value to “text_image”.
google_ad_channelQuoted String

Google provides the concepts of channels as a way to track ad performance.  For example, a publisher wishing to keep track of ad performance by ad type (image vs. text) could create separate channels and supply the applicable channel ID that corresponds to the ad type. In the way, the publisher can maximize revenue by displaying those ad types that generate the most clicks-thru’s.

Channel ID’s however must be created from within the AdSense dashboard before they can be used.

google_color_borderQuoted StringThis value determines the color of the ad border, and will also appear behind the “ads by Google” tag.  As with any of the following four color attributes, it has no affect when images ads are displayed.  All five also allow up to four separate values to be supplied, each separated by commas.  When done in this manner, the colors will be rotated automatically by the server.
google_color_bgQuoted StringThis value determines the background color of the ad.
google_color_linkQuoted StringThis value is the color of the ad title on ad units, and the color of the link in ad link blocks.
google_color_textQuoted StringThis value is the color of the text on ad units that appears in between the title and the URL. It is not used with ad link blocks.
google_color_urlQuoted StringThis value is the color of the URL at the bottom of each ad.  It is not used with ad link blocks.
google_ui_featuresQuoted StringTo better blend with various page designs, publishers can fine tune the appearance of the ad block.  For example, by supplying the text string “rc:” followed by the number 0, 6, or 10, a publisher can cause the corners of the ad block to be squared off, slightly rounded, or very rounded.
google_cpa_choiceQuoted StringIn addition to displaying ad links and ad units, another option for web marketers is the Google referral program.  While the most common of specifying referral units is thru the use of ad slots (in these cases the value of this stored on the server), it is possible to specify the referrer your after by including the referrer string as the value to this variable.  However, the values for this variable are somewhat elusive, and thus using intelligent programming logic to integrate them in your website may be difficult.  Thus, you may find that if using referrals, your best bet remains using the ad-slot method above.

If you’ve done some looking at the source of larger websites, you’ve probably noticed a few other interesting variables.  Keep in mind though, that unless you’re part of Google’s Premium AdSense program, using these variables won’t do you any good at best, and just might earn a frown from Google themselves.  It shouldn’t be too difficult to deduce what most of these variables do, but the reality is that if you’ve been able to develop a site that garners the 20 million-visitors-a-month requirement for the premium program, you’ll also earn access to technical assistance from Google to help integrate the advanced options that would be available to you, making any further elaboration here unnecessary.

google_adtestgoogle_max_num_ads
google_languagegoogle_encoding
google_safegoogle_ad_section
google_ad_output  

Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
 
Please input the anti-spam code that you can read in the image.

3.20 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
Next >