Difference between revisions of "Widget:AdSense"

From yidtravel
Jump to: navigation, search
 
Line 1: Line 1:
{{Widget
+
<noinclude>__NOTOC__
|author=Ike Hecht
+
This widget allows you to embed '''[//www.google.com/adsense/ AdSense ads]''' on your wiki page.
|provider=Google AdSense
+
|providerurl=http://www.google.com/AdSense‎/
+
|addedon=10/3/2013
+
}}
+
{{Comments}}
+
This widget allows you to add [http://www.google.com/AdSense‎/ Google AdSense] ads to your wiki page. Ads are placed in specific spots within the page - not in the skin.
+
  
== Example ==
+
Created by Ike Hecht for [//www.wikiworks.com WikiWorks].
  
To insert this widget, use the following code:
+
== Using this widget ==
 +
For information on how to use this widget, see the [http://www.mediawikiwidgets.org/AdSense widget description page on MediaWikiWidgets.org].
  
=== Code from Google ===
+
== Copy to your site ==
In Google AdSense, click "Get code". Copy that code. It will look similar to this:
+
To use this widget on your site, just install the [http://www.mediawiki.org/wiki/Extension:Widgets MediaWiki Widgets extension] and copy the [{{fullurl:{{FULLPAGENAME}}|action=edit}} full source code] of this page to your wiki as '''{{FULLPAGENAME}}''' article.
 
+
</noinclude><includeonly><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<pre><script type="text/javascript"><!--
+
<ins class="adsbygoogle <!--{$name|escape:html}-->"
google_ad_client = "ca-pub-4602712147397250";
+
     style="display:inline-block;width:<!--{$width|escape:'int'}-->;height:<!--{$height|escape:'int'}-->"
/* 160x600, created 1/1/10 */
+
     data-ad-client="<!--{$client|escape:html}-->"
google_ad_slot = "6127367636";
+
     data-ad-slot="<!--{$slot|escape:html}-->"></ins>
google_ad_width = 160;
+
google_ad_height = 600;
+
//-->
+
</script>
+
<script type="text/javascript"
+
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
+
</script></pre>
+
 
+
=== Code in the wiki ===
+
Take the values from above and place them in a widget call, as below.
+
 
+
<nowiki>{{#widget:</nowiki>{{PAGENAME}}<nowiki>
+
|name=myadname
+
|client=ca-pub-4602712147397250
+
|slot=6127367636
+
|width = 160
+
|height = 600
+
}}</nowiki>
+
 
+
==== Parameters ====
+
* '''name''' - The ad name in the AdSense system - this is only required for responsive ads
+
* '''client''' - Your AdSense Publisher ID - '''NOTE: It is highly recommended that you hard-code the client ID onto the widget page (Widget:AdSense). Otherwise, users will be able to insert their own ID and make money off of your site.'''
+
* '''slot''' - The AdSense Slot ID for this ad
+
* '''width''' - The desired width for this ad
+
* '''height''' - The desired height for this ad
+
 
+
== Responsive Example ==
+
 
+
The Widget was designed to work with responsive ads as well. Usage is similar.
+
 
+
=== Code from Google ===
+
In Google AdSense, click "Get code". Copy that code. It will look similar to this:
+
 
+
<pre><style>
+
.responsive-1 { width: 320px; height: 50px; }
+
@media(min-width: 500px) { .responsive-1 { width: 468px; height: 60px; } }
+
@media(min-width: 800px) { .responsive-1 { width: 728px; height: 90px; } }
+
</style>
+
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
+
<!-- Responsive 1 -->
+
<ins class="adsbygoogle responsive-1"
+
     style="display:inline-block"
+
     data-ad-client="ca-pub-4602712147397250"
+
     data-ad-slot="6127367636"></ins>
+
 
<script>
 
<script>
 
(adsbygoogle = window.adsbygoogle || []).push({});
 
(adsbygoogle = window.adsbygoogle || []).push({});
</script></pre>
+
</script></includeonly>
 
+
=== Code in the wiki ===
+
 
+
==== CSS ====
+
Take the values from the above <style> section and add the following CSS to your wiki, either by inserting it into your Mediawiki:Common.css, or by adding it to your skin. More info is available [https://www.mediawiki.org/wiki/CSS here].
+
<pre>
+
.responsive-1 { width: 320px; height: 50px; }
+
@media(min-width: 500px) { .responsive-1 { width: 468px; height: 60px; } }
+
@media(min-width: 768px) { .responsive-1 { width: 728px; height: 90px; } }
+
</pre>
+
==== Widget Call ====
+
Take the values from the above <script> section and place them in a widget call, as below.
+
 
+
<nowiki>{{#widget:</nowiki>{{PAGENAME}}<nowiki>
+
|name=responsive-1
+
|client=ca-pub-4602712147397250
+
|slot=6127367636
+
}}</nowiki>
+
 
+
<!-- Putting a sample here raises ethical questions. == Sample result ==
+
{{#widget:{{PAGENAME}}
+
|param1=
+
|param2=
+
|param3=
+
}}-->
+

Latest revision as of 21:42, 19 February 2015

This widget allows you to embed AdSense ads on your wiki page.

Created by Ike Hecht for WikiWorks.

Using this widget

For information on how to use this widget, see the widget description page on MediaWikiWidgets.org.

Copy to your site

To use this widget on your site, just install the MediaWiki Widgets extension and copy the full source code of this page to your wiki as Widget:AdSense article.