Adsense Ad Slot Id
Make a note of the ID of your ad unit and also your AdSense Publisher ID and paste these values in Line #15 and #18. Next, copy-paste the above snippet anywhere on your web page and, based on the size of the user’s device, the most appropriate AdSense Ad will be served. Once you have the Publisher ID and Ad Slot ID entered (or imported) you can change ad type, ad size (fixed, fixed by viewport or responsive) and ad type for AMP pages. Once you are happy with the settings click on the generate button and the the plugin will generate ad code for the AdSense ad in the code window of the current block. Sign in to google adsense ad account. Click on Ads and go to Ad Unit. Create new Ad unit, choose recommended display Ads. Copy and edit the script below. Edit the Publisher ID and Ad Slot. Add the code to your site, save and visit to see the changes.
AdSense program policies do not permit any alteration to AdSense code which artificially inflates ad performance or harms advertiser conversions.
Your publisher account offers a number of options when generating the ad code, which AdSense hope will allow you to create an ad layout that fits in with your site.
In general, AdSense recommend copying and pasting the ad code. In some situations though, AdSense understand that modifications are crucial to a clean user experience.
Adsense Ad Slot Ideas
Techniques to avoid
Here are some techniques you’ll want to avoid:
- Hiding ad units at anytime (e.g.,
display
:none
), unless you’re implementing a responsive ad unit - Implementing AdSense ad code in a way that covers content or where content covers ads
- Placing ad units on a mobile site or a responsive design site in such a way which will cause content and ads to overlap
- Manipulating the ad targeting using hidden keywords, IFRAMEs, or any other method
- Distributing ads in emails or software
- Manipulating the delivery or presentation of the ad to attract unwarranted attention (e.g., ads sliding into the screen, ads zooming in/out).
- Triggering an ad click during user drag actions on a mobile web page.
Acceptable modifications
Here are some acceptable modifications:
Responsive design
The new asynchronous ad code allows you to set the size of an ad through CSS, and optionally media queries, to fit in with your responsive site. Learn more about how to use responsive ad units.
A/B testing
AdSense experiments allow you to compare the performance of different ad type and/or text ad style settings of your ad units. Experiments help you make informed decisions about how to configure your ad units and can help you to increase your earnings.
Learn more about experiments.
Should you need more control over your A/B tests, please see the following code snippets:
- Synchronous ad code:
<script type='text/javascript'>
var random_number = Math.random();
google_ad_client = 'ca-publisher-id';
google_ad_width = 728;
google_ad_height = 90;
if (random_number < .5){
google_ad_slot = '1234567890';
} else {
google_ad_slot = '2345678901';
}
</script>
<script type='text/javascript'
src='https://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script> - Asynchronous ad code:
<script async src='https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>
<ins
>
</ins>
<script>
if (Math.random() < .5) {
mySlotId = '1234567890';
} else {
mySlotId = '2345678901';
}
(adsbygoogle = window.adsbygoogle []).push({
params: { google_ad_slot: mySlotId }
});
</script>
Adsense Ad Slot Idea
Setting custom channels dynamically
- Synchronous ad code:
<script type='text/javascript'>
var channel_condition = object.booleanMethod();
google_ad_client = 'ca-publisher-id';
google_ad_slot = '1234567890';
google_ad_width = 728;
google_ad_height = 90;
if (channel_condition){
google_ad_channel = '123457789';
} else {
google_ad_channel = '263477489';
}
</script>
<script type='text/javascript'
src='https://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script> - Asynchronous ad code:
<script async src='https://pagead2.googlesyndication.com/pagead/adsbygoogle.js'>
<ins
>
</ins>
<script>
channel_condition = object.booleanMethod();
if (channel_condition) {
my_google_ad_channel = '123457789';
}
else {
my_google_ad_channel = '263477489';
}
(adsbygoogle = window.adsbygoogle []).push({
params: { google_ad_channel: my_google_ad_channel}
});
</script>
Ad tag minification
- Synchronous ad code:
<script type='text/javascript'>
google_ad_client = 'ca-publisher-id';
google_ad_slot = '1234567890';
google_ad_width = 728;google_ad_height = 90;
</script>
<script type='text/javascript'
src='https://pagead2.googlesyndication.com/pagead/show_ads.js'>
</script> - Asynchronous ad code:
<script async src='https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>
<ins
></ins>
<script>(adsbygoogle = window.adsbygoogle []).push({});</script>
For details on what alterations you’re permitted to make to AdSense for search code, see the AdSense for search policies.