Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Google adsense and other ads service like adsense don't work well on full ajax mode site. So, from 4.4.0 we make a new setting alow you turn off full ajax mode.

 

This tutorial will work for any type of ad with javascript

As an Admin you can create HTML based ads direct from your AdminCP by creating a new block, choosing HTML as the block type. This is what we will use for our Google ads.

When making your ad at Google, please be sure your code is async.

Original ads code from google:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- myad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="mypub"
data-ad-slot="myadslot"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

In order for the ad to display properly, we need to add the $Behavior function as shown below in the last <script> tag.

New code:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- myad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="mypub"
data-ad-slot="myadslot"
data-ad-format="auto"></ins>
<script>
$Behavior.googleads = function(){
(adsbygoogle = window.adsbygoogle || []).push({});
};
</script>

Place the HTML code in the code input area for the new block and set the location (where on the page you want it) and controller (which page should it show on). For our screenshot below of a google ad, we chose Sitewide as the controller as we want it all over the site.

Note: If you create more than 1 ads unit, please change "googleads" (in $Behavior.googleads), because this is unique text.

  • No labels