Archived topic
need adjustment in hook
7 replies · Started by Shivam on November 11, 2019
Hey team,
I wanted to add different Adsense code for mobile and desktop through Hook feature as I am already using page hero feature for title.
So, i added the code like this in the hook
<div class="hide-on-mobile hide-on-tablet">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Header -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-24866347457758179588"
data-ad-slot="1922343180"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div class="hide-on-desktop">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Header mobile -->
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-248663475678179588"
data-ad-slot="4861838462"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
but I don't know why only desktop ad is appearing on all devices.
Hi there,
Did you resolve the issue as it is working on my browsers?
no i have not resolved the issue i am currently using that code via page hero... Tell me how can i use that with the hook feature as i want to use page hero for heading...
You can try adding the hide-on-* class to the <ins class="adsbygoogle"> element.
Generally its best practice to use responsive ads as opposed to calling two different scripts.
I didn't get it, can you please rearrange my code with the necessary tag?
Like so:
<div class="grid-container">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Header -->
<ins class="adsbygoogle hide-on-mobile hide-on-tablet"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-24866347457758179588"
data-ad-slot="1922343180"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<div class="grid-container">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Header mobile -->
<ins class="adsbygoogle hide-on-desktop"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-248663475678179588"
data-ad-slot="4861838462"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
Hey if i want to add margin and keep the ad in center then what i will need to do?
Edit the code above to include the grid container.