How to Add Amazon Associate Custom Popover Ads
Amazon associate provides mobile popover ads. But, what if we want to add a desktop version.
Sample Code
<button onclick = "myCustomAzAd.style.visibility = 'visible'">Show Ad</button> <div id="myCustomAzAd" style="background-color: grey; border: 1px solid; bottom: 1px; height: 100%; position: fixed; width: 100%; z-index: 9999;"> <span class="hideAd" onclick="myCustomAzAd.style.visibility = 'hidden';">X</span> //Amazon Ad code here <div id="amzn-assoc-ad-xxxfdexx-3xxx-4xxxx-bxxx-axfxxxxxxbb"></div> <script async="" src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=00xxxxxx-3xef-xxxxe-xxxx-xxxxxxxx"> </script> </div>
X
You can also set the ad to apear every some period.
<div id="myCustomAzAd" style="opacity:0.95;top:0;left:0;background-color: grey; border: 1px solid; bottom: 1px; height: 100%; position: fixed; width: 100%; z-index: 9999;">
<span class="hideAd" onclick="myCustomAzAd.style.visibility = 'hidden';">X</span>
//Amazon Ad code here
<div id="amzn-assoc-ad-xxxfdexx-3xxx-4xxxx-bxxx-axfxxxxxxbb"></div>
<script async="" src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=00xxxxxx-3xef-xxxxe-xxxx-xxxxxxxx">
</script>
<script>
setInterval(()=>{
myCustomAzAd.style.visibility = 'visible';
},10000);
</script>
</div>
Key Points
To toggle hide and show of the ad container, we cannot use display = 'block' or 'none'. It just dose not work. After hiding and showing the ad container, Amazon Ad will not show up with no error messages. We have to use visibility instead.
You can also make a amaon ad floating at the bottom of the web browser.
<div style = "position:fixed;bottom:0;text-align:center">
<div class="alignleft">
<script type="text/javascript">
amzn_assoc_ad_type = "banner";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_placement = "assoc_banner_placement_default";
amzn_assoc_campaigns = "prime_up";
amzn_assoc_banner_type = "category";
amzn_assoc_p = "48";
amzn_assoc_isresponsive = "false";
amzn_assoc_banner_id = "xxxxxxxxx8R7KG782";
amzn_assoc_width = "728";
amzn_assoc_height = "90";
amzn_assoc_tracking_id = "axxxxx-xx";
amzn_assoc_linkid = "xx8xx6xxxc862fdc";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/q?xxxxceVersion=xxxxxxxOperation=GetScriptxID=OneJSxxx=x">
</script>
</div>
</div>
Comments
Post a Comment