Extension talk:WimaAdvertising

About this board

Not Show any ad in vector

26
Tunglinwu (talkcontribs)

I use this extension.

When I no set $wmGoogleAdSense* series, because I set auto ad in adsense, not show any ad.

And I set '$wmGoogleAdSense* series, it only show "Advertisement" area, and not show any ad.

WikiForMen (talkcontribs)

First: Enable Google Adsense $wmGoogleAdSense = true;

Second: Define slots $wmGoogleAdSense_AD1= [ 'slotid 1', 145, 260 ]; $wmGoogleAdSense_AD2= [ 'slotid 2', 145, 260 ]; $wmGoogleAdSense_Top= [ 'slotid 3', 145, 260 ]; $wmGoogleAdSense_Bottom = [ 'slotid 4', 145, 260 ];

Third: $wmGoogleAdSenseClient = 'pub-your_number'; $wmGoogleAdSenseID = 'any text but empty';

Do not forget to set AD1 and AD2 in MediaWiki:Sidebar, if you use the slots in the sidebar.


See i.e.

view-source:https://41.wikimannia.org/index.php?title=Zollunion_des_S%C3%BCdlichen_Afrika

and look for "slotid 1", "slotid 2", "slotid 3", and "slotid 4".

Settings are: $wmWimaAdvertising = false; $wmGoogleAdSense = true; $wmGoogleAdSense_AD1= [ 'slotid 1', 145, 260 ]; $wmGoogleAdSense_AD2= [ 'slotid 2', 145, 260 ]; $wmGoogleAdSense_Top= [ 'slotid 3', 145, 260 ]; $wmGoogleAdSense_Bottom = [ 'slotid 4', 145, 260 ]; $wmGoogleAdSenseClient = 'pub-9471398824076666'; $wmGoogleAdSenseID = 'ID 007'; $wmGoogleAdSenseSrc = 'https://pagead2.google_syndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxx';

I can't test this any further because I don't have a Google Adsense account.

It shows:

<script type="text/javascript" src="https://pagead2.google_syndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxx">
</script>
<script type="text/javascript"><!--
google_ad_client = "pub-9471398824076666";
/* ID 007 */
google_ad_slot = "slotid 3";
google_ad_width = 145;
google_ad_height = 260;
google_language = "de";
google_encoding = "utf8";
// -->
</script>

--WikiForMen (talk) 22:53, 14 August 2024 (UTC)

WikiForMen (talkcontribs)

If you really did not make a configuration error and it does not work, please try version 2.4.0 of WimaAdvertising and give me a report.--WikiForMen (talk) 23:11, 14 August 2024 (UTC)

Tunglinwu (talkcontribs)

Thanks for reply,

I use 2.4.0, it's a:so can't show anything.

wfLoadExtension( 'WimaAdvertising' );

$wmGoogleAdSense  =  true ;

$wmGoogleAdSenseAnonOnly = false;

$wmGoogleAdSenseClient = 'pub-*';

$wmGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';

$wmGoogleAdSense_AD1 =  [  'xxxxx' ,  'auto' ,  'auto'  ];

$wmGoogleAdSense_AD2 =  [  'xxxxx' ,  'auto' ,  'auto'  ];

$wmGoogleAdSense_Top =  [  'xxxxxx' ,  'auto' ,  'auto'  ];

$wmGoogleAdSense_Bottom  =  [  'xxxxx' ,  'auto' ,  'auto'  ];

By the why, it will cover my Sitenotice content.

WikiForMen (talkcontribs)

"can't show anything" AND "it will cover my Sitenotice content"?!??

How can it cover your Sitenotice content, if it didn't show anything.

By the way, this is nearly impossible.

Please use the link:

view-source:https://41.wikimannia.org/index.php?title=Zollunion_des_S%C3%BCdlichen_Afrika

and look for "slotid 1", "slotid 2", "slotid 3", and "slotid 4".

view-source:https://yourdomain.org

and look into your own HTML-Sourcecode.

It should show something.

At least I see inserted HTML code on "41.wikimannia.org", although no ads are displayed for me either, which is due to the fact that I do not have a Google AdSense account, so the link to Google AdSense does not take effect.

Could you please give me the URL of your wiki so that I can take a look at the HTML source code on your page?--WikiForMen (talk) 13:14, 15 August 2024 (UTC)

Tunglinwu (talkcontribs)

like this:

mystie

I set 4, but source only show 1.

If top show "Advertising:"(text) and replace my sitenotice, and no any ad.

WikiForMen (talkcontribs)

The ad at the top should alter randomly with sitenotice.

As I told you, you should set AD1 and AD2 in MediaWiki:Sidebar:

* navigation
**mainpage|mainpage-description
**recentchanges-url|recentchanges
**randompage-url|randompage
**helppage|help-mediawiki
* AD1
* 主要
**ガチャ|ガチャ
**楽曲|楽曲
* メンバー
**日野下花帆|日野下花帆
**村野さやか|村野さやか
**乙宗梢|乙宗梢
**夕霧綴理|夕霧綴理
**大沢瑠璃乃|大沢瑠璃乃
**藤島慈|藤島慈
**百生吟子|百生吟子
**徒町小鈴|徒町小鈴
**安養寺姫芽|安養寺姫芽
* SEARCH
* AD2
* TOOLBOX
* LANGUAGES

In the HTML-Code I see:

<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<div id="siteNotice" class="notheme"><div style="clear:both; margin-top:1em; text-align:left;"><p>Advertising:</p><div style="border:1px solid black; text-align:center;"><script type="text/javascript"><!--
google_ad_client = "pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 0;
google_ad_height = 0;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script></div>

<syntaxhighlight lang="php">
<div style="clear:both; margin-top:1em; text-align:left;" id="siteNotice"><p>Advertising:</p><div style="border:1px solid black; text-align:center;"><script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script type="text/javascript"><!--
google_ad_client = "pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 0;
google_ad_height = 0;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script></div>

So this is more than nothing!

As I see you use slot "5512254708" twice!

google_ad_width = 0;
google_ad_height = 0;

OOPS! "width" and "height" set to 0! :-(

Do not use 'auto' for the moment until this is fixed!

I found this information:

Especially with responsive themes you would need responsive ad units, because the normal ad sizes are not checking if they fit into your theme.
Source: https://webgilde.com/en/adsense-auto-resizing-error/

It seems, that "responsive" and "auto" are not working with normal ad units. How to deal with "responsive ad units" I have to investigate...



In the case, avoiding 'auto' for "google_ad_width" and "google_ad_height" don't solve the issues, try WimaAdvertising in Version 2.4.1. You get it here. It should give you this:

<div style="clear:both; margin-top:1em; text-align:left;" id="siteNotice">
Advertising:<div style="border:1px solid black; text-align:center;"><script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script type="text/javascript"><!--
google_ad_client = "pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 450;
google_ad_height = 620;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script>
<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">

</script></div>

I installed it here:

view-source:https://42.wikimannia.org/index.php?title=Spezial:Version

Try it and give me a report please! --WikiForMen (talk) 22:39, 15 August 2024 (UTC)

Tunglinwu (talkcontribs)

I try only put 1 ad in the Sidebar, but Advertising also not show (v2.4.1) source show these:

<div class="after-portlet after-portlet-wimaadvertising-advertising"><script type="text/javascript"><!--
google_ad_client = "ca-pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 120;
google_ad_height = 300;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script>
<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script></div>
WikiForMen (talkcontribs)

The source looks good!

I really don't know why nothing is displayed, not even "Advertising":

<div class="vector-menu-heading">
Advertising
</div>

We have not yet tested with MediaWiki 1.43 and especially with Skin Vector (2022). I found the Donate button in the right sidebar. This shows me that our extensions work in principle. You can also see the ad entry in the source code. So I suspect that the Vector skin has some peculiarities in the way it handles sidebars.

Here:

https://42.wikimannia.org/index.php?title=MediaWiki:Sidebar

I can see "Advertising" twice in the sidebar. OK, only the label "Advertising" because I have no Google AdSense account, so no Ad is provided, but the source code is inserted and the label visible.

By the way: Have you installed an AdBlocker? That would explain why the source code is available but nothing is displayed ;-)

At least the issue with width and height has been resolved:

google_ad_width = 120;
google_ad_height = 300;

Please try:

$wmGoogleAdSense_Bottom = [ 'xxxxx', 1200, 240 ];

Please try also

$wgDefaultSkin = 'vector'; // "Legacy" Vector (2010)

or

$wgDefaultSkin = 'monobook';

Happy testing! ;-)

Tunglinwu (talkcontribs)

I have tried vector and monobook, but also not show anything.

I also tried edit size, but not show anything.

(Have closed any extensions. When adblock open, it show page have ad.)

I open the site in the cell phone and ipad, also not show ad.

WikiForMen (talkcontribs)

A look into the HTML code shows, that the extension is working.

You should test, if Google AdSense is well configured:

Please test two simple HTML pages:

<html>
<head
<title>Google AdSense test with js-script-file in the header section</title>
<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
</head>
<body>
<h2>This is a Google AdSense test</h2>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 120;
google_ad_height = 300;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script>
</body>
</html>
<html>
<head
<title>Google AdSense test with js-script-file NOT in the header section</title>
</script>
</head>
<body>
<h2>This is a Google AdSense test</h2>

<script type="text/javascript"><!--
google_ad_client = "ca-pub-9543960077946929";
/* none */
google_ad_slot = "5512254708";
google_ad_width = 120;
google_ad_height = 300;
google_language = "zh-tw";
google_encoding = "utf8";
// -->
</script>
<script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" />
</body>
</html>
Tunglinwu (talkcontribs)

Also not show ad, i use other code can show ad.

WikiForMen (talkcontribs)

I did an online research and found, Google AdSens code has changed. The extension is adapted in version 2.8.2.--WikiForMen (talk) 15:37, 21 August 2024 (UTC)

WikiForMen (talkcontribs)

Can you please share this code? If Google AdSense has changed the code, we are not aware of it.

Tunglinwu (talkcontribs)

I only know official js is : https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-number

and single banner code is:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-number"
     crossorigin="anonymous"></script>
<!-- BANNER -->
<ins class="adsbygoogle"
     style="display:inline-block;width:120px;height:300px"
     data-ad-client="ca-pub-number"
     data-ad-slot="5512254708"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
WikiForMen (talkcontribs)

The AdSense code has therefore changed. What is taken into account in WimaAdvertising version 2.8.2. Good luck!

Tunglinwu (talkcontribs)

I have update to v2.8.2, also not show.

WikiForMen (talkcontribs)

In the source code of your site I can see the following:

<div id="p-wimaadvertising-advertising" class="vector-menu mw-portlet mw-portlet-wimaadvertising-advertising">
<div class="vector-menu-heading">
Advertising
</div>
<div class="vector-menu-content">
<ul class="vector-menu-content-list">
</ul>
<div class="after-portlet after-portlet-wimaadvertising-advertising">
<ins class="adsbygoogle" style="display:inline-block;width:120px;height:300px;" data-ad-client="ca-pub-pub-9543960077946929" data-ad-host="ca-host-pub-" data-ad-slot="5512254708" data-ad-format="vertical"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
</div>
</div>
</div>

This means that the extension is working.

data-ad-host="ca-host-pub-"

You have obviously not specified the data-ad-host variable!

As I do not use AdSense myself, I have no idea whether it is necessary to specify these variables. If this is the case, I would have to intercept this special case separately.

Please experiment with the simple HTML file beforehand to separate AdSense configuration issues from MediaWiki or extension issues!!!

The portlet ‘mw-portlet-wimaadvertising-advertising’ is also displayed at the bottom left of the sidebar:

Advertising

This also means that there are no fundamental display issues.

Other reasons could be possible:

Why are Google AdSense ads not showing up properly on my website?

There could be several reasons why Google AdSense ads are not displaying properly on your website:

1> Incorrect Ad Code Implementation: Make sure you have implemented the AdSense ad code correctly on your website. Double-check that you’ve copied and pasted the code provided by AdSense without any errors.
2> Ad Placement Violations: Google has strict policies regarding ad placement. Ensure that you’re not violating any of their policies by placing ads too close to certain content, such as adult content or copyrighted material.
3> Ad Blocking Software: Some visitors might be using ad-blocking software, which prevents AdSense ads from displaying on your website. Unfortunately, this is something beyond your control.
4> Not Enough Content: AdSense requires a sufficient amount of content on your website to serve relevant ads. If your website has very little content or low-quality content, AdSense might struggle to find suitable ads to display.
5> AdSense Account Issues: Check if your AdSense account is active and in good standing. Sometimes, AdSense accounts get suspended or disabled due to policy violations or other reasons, which would prevent ads from displaying.
6> Technical Issues: There could be technical issues with your website or with Google’s ad serving system. Check for any errors in your website’s code or server configuration that might be preventing the ads from loading.
7> Geographical Restrictions: Certain ads might be geo-targeted, meaning they are only displayed to visitors from specific countries. If your website receives traffic from countries where certain ads are not available, those ads might not display.
8> Low Traffic: If your website has very low traffic, AdSense might not be able to find relevant ads to display. Increasing your website’s traffic could potentially improve ad visibility.
If you’ve checked all these points and are still experiencing issues, you might want to reach out to Google AdSense support for further assistance.

https://www.quora.com/Why-are-Google-AdSense-ads-not-showing-up-properly-on-my-website



Submit your site for review

Building a high-quality site takes effort and time. When you’ve addressed the above points, submit your site for review through the Sites page in your AdSense account.
Sign in to your AdSense account.
Click Sites.
In the list of sites, click the site that needs review.
Confirm you've placed the AdSense code on your site. Learn more about pasting ad code in our code implementation guide.
Click Next.
Click Request review.
The review process usually takes a few days, but in some cases can take 2-4 weeks. We'll let you know when we've completed the checks and your site is ready to show ads.

https_support.google.com/adsense/answer/12176698?hl=en

WikiForMen (talkcontribs)

We need to make sure that you have correctly configured and activated your Google AdSense account. Therefore, please test this simple HTML file:

<html>
<head>
<meta charset="UTF-8"/>
<title>WimaAdvertising – Test 1</title>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9543960077946929" crossorigin="anonymous"></script>
</head>
<body>
<div style="border:solid green 15px;">
<ins class="adsbygoogle"
    style="display:inline-block;width:120px;height:300px;"
    data-ad-client="ca-pub-9543960077946929"
    data-ad-slot="5512254708"
    data-ad-format="vertical"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</body>
</html>
Tunglinwu (talkcontribs)

I try it, but it only show a green box. By the why, I also to read google ad offcial code, There is no need for this code:data-ad-host. Now I use other code, it's normal.

WikiForMen (talkcontribs)

I removed data-ad-host in version 2.8.3, but I still can not see any ad on your page...

WikiForMen (talkcontribs)

I'm desperately trying to figure out which AdSense code works. It's certainly not the extension.

Tunglinwu (talkcontribs)

It seems runned, ad showed, but not put in sidebar in desktop,mobile sometimes will show. BTW, the google adsense official code style without ";" at the end, like this:

style="display:inline-block;width:120px;height:300px"

and dev tool will show error:

adsbygoogle.js:172 Uncaught TagError: adsbygoogle.push() error: No slot size for availableWidth=0
    at qo (adsbygoogle.js:172:327)
    at po (adsbygoogle.js:171:147)
    at zo (adsbygoogle.js:176:104)
    at Fo (adsbygoogle.js:190:29)
    at lq (adsbygoogle.js:216:105)
    at kq (adsbygoogle.js:215:620)
    at uq (adsbygoogle.js:232:173)
    at e.client (adsbygoogle.js:224:43)
    at $e.ga (adsbygoogle.js:59:239)
    at ak (adsbygoogle.js:97:19)
WikiForMen (talkcontribs)

Confusing: "seems runned, ad showed" ... "dev tool will show error" ...

The ";" at the end makes a difference?!?? It should not...

The error show is with or without ";"?

I can remove it, if this causes problems...

What about

data-ad-format="vertical"

?

So I did Version 2.8.3.1 (for testing).

Tunglinwu (talkcontribs)

I dont know, I think ";" is needed, but google adsense offcial code without it.

And I know what happened, I opened auto ad, so the ad will also show Anchor ads & In-page formats.

So v2.8.3 can be used normally, thanks for your work and help.

WikiForMen (talkcontribs)

These HTML snippets have the charm of the 1980s, when every HTML page was hand-coded and such snippets were inserted individually.

This is a far cry from today's practice, where HTML pages are generated automatically and the solutions also have to work in a generalised way for many websites. It is a hopeless mess...

The last ";" is optional. In general, the Css stuff should only be interpreted by the reader's browser and not by Google AdSense. But let's leave it at that.

Happy "websiting"! ;-)

Reply to "Not Show any ad in vector"

Can add support to the Citizen Skins

4
Summary by WikiForMen

Skin Citizen is (partially) supported.

Danielyepezgarces (talkcontribs)

I contacted the skin developer and they told me that they could support the skin.

It would be good if the extension continued to have more compatibility with more skins

WikiForMen (talkcontribs)

Skin Citizen has no Sidebar, so there is no support for $wmSidebarAd1Code and $wmSidebarAd2Code.

But you can use $wmBannerBottomCode and $wmBannerTopCode simply by alter line 44 in file Hooks.php from

		} else if ( $skinname !== 'fallback' ) {

into

		} else if ( !in_array( $skinname, [ 'citizen', 'fallback' ] ) ) {
Danielyepezgarces (talkcontribs)

It works well, another suggestion would be that it can be hidden for a specific user group and not only for logged in users

WikiForMen (talkcontribs)

Can you be more specific? What do you mean with "specific user group"?

Reply to "Can add support to the Citizen Skins"

Colon element when type is blank

2
Summary by WikiForMen

Solved in version 2.7.1

2A00:23C6:2006:9701:61EC:93F9:CEC3:DD63 (talkcontribs)

When setting the banner type to blank there is still a ':' symbol and linebreak where the text 'advertising:' would otherwise be by default.

It looks like the colon is being appended to the type's value even if this value is blank.

Running MediaWiki 1.40.1

WikiForMen (talkcontribs)

I see that this only affects the slots at the top and at the bottom.

We have solved this in version 2.7.1.

Thank you for your report.

pagead2.googlesyndication.com

4
Summary by WikiForMen

Issue is solved.

Redundant-decadence (talkcontribs)

I do not want to use the extension for Google Ads, just for my own content. However, there is a call to pagead2.googlesyndication.com. Luckily, this is prevented by my CSP settings:

Refused to load the script 'https://pagead2.googlesyndication.com/pagead/show_ads.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' blob: 'self' 'unsafe-inline'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

For privacy reasons, I do not want any calls to Google servers, or any other 3rd-party requests, except those I selected carefully. Can I prevent this with configuration settings? This is my current configuration:

wfLoadExtension( 'WimaAdvertising' );

$wmWimaAdvertising = true; $wmWimaAdvertisingAnonOnly = false; $wmSidebarAd1Type = "advertising"; $wmSidebarAd1Code = '<a href="https://www.7gutegruende.de/planspiel-hvr/"><img src="https://roter-kreis.de/images/f/fd/7GG-e069-2023-12-23-Planspiel-HVR_500.png" alt="Spielst du noch oder lernst du schon? Planspiel zum humanitären Völkerrecht" /></a>';

$wmSidebarAd1Style = ;

$wmGoogleAdSense is false (by default). Setting it to false does not change anything.

Any idea?

WikiForMen (talkcontribs)

The problem is that $wmGoogleAdSenseSrc is set per default to //pagead2.googlesyndication.com/pagead/show_ads.js

Solution: Set $wmGoogleAdSenseSrc to an empty string and the issue should have gone.

Redundant-decadence (talkcontribs)

Great! This solved my problem. Thank you!

WikiForMen (talkcontribs)

I have fixed the issue. Now it is ensured that the variable $wmGoogleAdSense is set to true before the script $wmGoogleAdSenseSrc is included.

Redundant-decadence (talkcontribs)

I suggest to add an additional BannerType: 'recommendation'.

WikiForMen (talkcontribs)

'Hint' or 'recommendation' is basically the same thing, the choice of words depends on personal preference. You can of course customise the extension by changing the corresponding entry in the i18n/en.json file.

I have just added the BannerType 'blank' in version 2.6.0.

Redundant-decadence (talkcontribs)

Thank you, very much.

WikiForMen (talkcontribs)

Merry Christmas!

Problems with Sidebar on Vector w/ MediaWiki 1.36.1

3
Summary by WikiForMen

Issue should be resolved with version 2.3.0.

2601:182:CA02:94A0:990C:DF16:18FD:42E9 (talkcontribs)

Hi everyone,

I'm encountering a problem getting Wima Advertising to function in the AD1 and AD2 sidebar slots on the Vector skin included with MediaWiki 1.36.1. I attempted to apply the patch specified for Vector in 1.35, but the file located at "includes/VectorTemplate.php" no longer exists. Please update the page with instructions for 1.36.1, thanks!

WikiForMen (talkcontribs)
WikiForMen (talkcontribs)

No Adsense code added to MediaWiki

25
Summary by WikiForMen

An issue with skin Timeless has been resolved in version 2.4.1.

Costas Athan (talkcontribs)

Here is the code I have added to LocalSettings.php:

wfLoadExtension( 'WimaAdvertising' );

$wmGoogleAdSense = true;
$wmGoogleAdSenseClient = 'ca-pub-xxxxxxxxxxxxxxx';
$wmGoogleAdSense_AD1 = [ '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxx" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx" data-ad-format="auto"  data-full-width-responsive="true">
</ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', 145, 260 ];
$wmGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxx';

This has as a result no ad related code do be added anywhere in the HTML source.

I have also tried instead of setting $wmGoogleAdSense_AD1 to use Manual:Hooks/SkinAfterPortlet. Here is the relative code:

$wgHooks['SkinAfterPortlet'][] = function($skin, $portletName, &$html) {$user = $skin->getUser();
if ($portletName === "tb") {
$html = <<< EOT
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxxxx" crossorigin="anonymous"></script>
<ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
    data-ad-slot="xxxxxxxxxx"
    data-ad-format="auto"
    data-full-width-responsive="true"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
EOT;
return true;
}
};

The addition of the hook reserves a space under the "Wiki Tools" section, but again no ads shown. I'm not sure if this has to do with AdSense itself though.

And just a final question. Shouldn't any AdSense code be added by the extension in the <header>? Now the only code added is the one by the SkinAfterPortlet hook. Shouldn't setting the $wmGoogleAdSenseSrc variable lead to an addition of related code in the header section?

WikiForMen (talkcontribs)
WikiForMen (talkcontribs)

Regarding to your question about AdSense code in the <header>: This job is done by the HeaderExtension. But I'm afraid that doesn't place adverts in the sidebar.

Costas Athan (talkcontribs)

If I'm not mistaken Google suggests to add the code which you assign to the $wmWimaGoogleAdSenseSrcvariable in the header section of the HTML. Maybe you should modify the WimaAdvertising extension to do just that, add that specific line of code in the header.

WikiForMen (talkcontribs)
Costas Athan (talkcontribs)

I tried to use your other Extension, HeaderExtension, for this particular reason, but I again got an error. I have started a topic in the discussion of HeaderExtension about it.

WikiForMen (talkcontribs)

OK, it is $wmGoogleAdSenseSrc not $wmWimaGoogleAdSenseSrc. I fixed this in the description. But the main problem is that the skin Timeless does not display adverts in the sidebar, while other skins do. I have just tested this and I asked you to do the same to rule out misconfigurations.

At the moment, placing $wmGoogleAdSenseSrc in the <head> section will not solve our problem. However, I will make a note of your suggestion for a later version.

Costas Athan (talkcontribs)

I know it won't solve the problem. I'm just pointing it out, that Google suggests this particular script to be placed within the header.

Well, I just tried MonoBook and Vector skins, without luck. Still no ad code added in the HTML. Note that this time I have already added * AD1 in the MediaWiki:Sidebar.

Are you sure the rest of the variables ($wmWimaGoogleAdSense, $wmWimaGoogleAdSenseClient, $wmWimaGoogleAdSense_AD1) are named correctly ?

WikiForMen (talkcontribs)

No, all $wmWimaGoogle… should be $wmGoogle….

Costas Athan (talkcontribs)

@WikiForMen

OK. I renamed all those variables I mentioned in my previous message and it seems that things work now, with the exception of Timeless skin. You should update their names in the Wiki.

Can this line of code

WikiForMen (talkcontribs)
Costas Athan (talkcontribs)

I hadn't. I just added it, then cleared Cloudflare cache, but it made no difference.

$wmGoogleAdSense_AD1= [ 'xxxxxxxxxx', 145, 260 ];

I tried both Fixed and Responsive ads, but also that made no difference.

The SkinAfterPortlet is probably working. I see the space reserved and the code injected in the HTML. I guess that another unrelated issue is preventing the ads from showing in the hook's case.

But is there a reason to use WimaAdvertising extension along with the hook?

WikiForMen (talkcontribs)

I developed WimaAdvertising before REL1_35, the hook SkinAfterPortlet was introduced with REL1_35. Due to changes in REL1_39 injecting HTML with the SkinBuildSidebar hook. I was told that as of REL1_35 the SkinAfterPortlet hook should do the job. And it works fine, but not for the Timeless skin. :-(

That's why I asked on the Timeless talk page what this is all about.

But I would ask you to switch to other skins - you can easily do that under your personal settings - and watch the sidebar under other skins to prevent misconfigurations.


The special reason to use WimaAdvertising is that you can fix css issues in the sidebar by editing the corresponding resources.

The extension SkinCustomiser, for example, allows you to customise standard skins. You may want to define a border or background colour for the sidebar blocks. However, this should not appear for the advertising banner blocks; this is done - among other things, such as the placement between the blocks (see * AD1, * AD2) - by the WimaAdvertising extension.

WikiForMen (talkcontribs)

I am still debugging. For now I figured out, that the hook SkinAfterPortlet is supported for skin Timeless. This is actually clear, because other extensions such as extension DonateButton also work in the same way and appear normally in Timeless. But I was initially confused due to the lack of explanations.

But for some reason all skins are fine with

* AD1

in MediaWiki:Sidebar.

For some reason I do not understand until now is, why skin Timeless works with

* AD1
**item_url|item

in MediaWiki:Sidebar.

The thing with AD1 and AD2 is a bit tricky, because these are placeholders for something that can be an advert, an event or a notice through individual configuration, which should also be translatable into different languages. It took me a lot of fiddling around until it finally worked as intended.

The good news for today is that WimaAdvertising basically also works for Skin Timeless. :-)

Now I just have to find out why Skin Timeless doesn't show the adverts when the list after AD1 or AD2 is empty.

WikiForMen (talkcontribs)

Now I understand what I also made a dirty hack for the DonateButton extension to make the Hook SkinAfterPortlet work for the Timeless skin.

So Timeless has a problem with Hook SkinAfterPortlet when the portlet is empty, that is, it contains no elements.

In GitHube I uploaded a new Version 2.4.1 that fixed it.

Costas Athan (talkcontribs)

Are you sure it works? I just installed version 2.4.1 and it still doesn't seem to work for me.

Here is my code:

$wmGoogleAdSense = true;
$wmGoogleAdSenseClient = 'ca-pub-XXXXXXXXXXXXXXXXX';
$wmSidebarAd1Type = "advertising";
$wmSidebarAd1Code = '<script>/* Adsense script */</script>';

When I assign the same Adsense script to: $wgHooks['SkinAfterPortlet'][] ads appear without an issue.

WikiForMen (talkcontribs)

$wmSidebarAd1Code is for the none Google AdSense.

In your case it should be:

$wmGoogleAdSense_AD1 = [ 'slot #', 145, 260 ];
$wmGoogleAdSenseClient = 'ca-pub-XXXXXXXXXXXXXXXXX';
$wmGoogleAdSenseID = 'ID-XXX';
$wmGoogleAdSenseSrc = '<script>/* Adsense script */</script>'

Now I will upload Version 2.5.0.

Costas Athan (talkcontribs)

Extension:WimaAdvertising#wgBannerCode You assign the AdSense script to $wmSidebarAd2Code. Is this possible only for AD2? Not for Ad1? That's confusing. I expected both AD1 and AD2 to have the same functionality.

By the way, is it possible to utilize responsive ads with this extension? As I see in the code hereː $wmGoogleAdSense_AD1= [ 'xxxxxxxxxx', 145, 260 ]; you have to mention width and height properties.

WikiForMen (talkcontribs)

Look at the documentation. You can define up to four ad units.

Example:

$wmGoogleAdSense_AD2 = [ 'slotid', width, height ];

I have added a new subheading in the documentation to make it clear that the section "Wima web slots" is not relevant for "Google Adsense" slots.

The thing with the "Wima web slots" is that there is no "Google Adsense" that provides the advertising data, there you can set your individual code to advertise a book or an event, for example. But that's not what you want. The WimaAdvertising extension offers both options. Originally, WimaAdvertising could only do the individual variant because it was what I needed. Later, I integrated the option "Google Adsense" because I assumed that there was a need for it. Of course, you then have to skip the settings for "Wima web slots".

Costas Athan (talkcontribs)

What about "Responsive" ads. Are they supported or only "Fixed" sized ones?

By the way on the "Wima web slots section" you have this codeː

$wmSidebarAd2Code = '<script type="text/javascript">
google_ad_client = "ca-pub-xxxxxxxxxxxxxxx";
google_ad_slot = "3512091103";
google_ad_width = 145;
google_ad_height = 260;
google_language = "en";
google_encoding = "utf8";
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js&amp;amp;amp;#x22;&amp;amp;amp;#x3E;&amp;amp;amp;#x3C;/script>';

which is an example of an AdSense script.

WikiForMen (talkcontribs)

And yes, in the "Wima web slots section" you find an example how you can do "Google AdSense" also on the "Wima web slot" way. :-)

But you have to decide for on way and follow it consistently.

WikiForMen (talkcontribs)
Costas Athan (talkcontribs)

OKǃ

Look my edit of my previous post about $wmSidebarAd2 code in "Wima web slots" section. You may want to edit this example.

WikiForMen (talkcontribs)

I have tried this

$wmWimaAdvertising = true;
$wmGoogleAdSense = false;
$wmSidebarAd1Code = '<script type="text/javascript">
google_ad_client = "ca-pub-xxxxxxxxxxxxxxx";
google_ad_slot = "3512091103";
google_ad_width = 145;
google_ad_height = 260;
google_language = "en";
google_encoding = "utf8";
</script>';
$wmGoogleAdSenseSrc = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxxxxxxxxxxxxx';

and it seems to work!

But this should do the same:

$wmWimaAdvertising = false;
$wmGoogleAdSense = true;
$wmGoogleAdSenseClient = 'ca-pub-xxxxxxxxxxxxxxx';
$wmGoogleAdSense_AD1 = [ '3512091103', 145, 260 ];
$wmGoogleAdSenseSrc = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
WikiForMen (talkcontribs)

New in 2.5.0

  • Place JavaScript for GoogleAdSense in `<head>` section.

Just as you suggested.

There are no older topics
Return to "WimaAdvertising" page.