Hi @Siropu , I have been using this code to make ads "sticky" in the sidebar. Unfortunately, this no longer works after the update from 2.2.16 to 2.3.3 (in Ads Manager 2.5.3). How do I have to modify the code? Thanks!Try this code just below you actual ad code (for position "Sidebar below"):
Code:<xf:js> $(function() { var unit = $('.samCodeUnit[data-position="container_sidebar_below"]'); if (unit.length) { var unitOffset = unit.offset().top; $(window).scroll(function() { var unitScrollOffset = unit.offset().top; var scrollTop = $(document).scrollTop(); if (unitScrollOffset - scrollTop <= 0) { unit.css({position: 'fixed', top: $('.p-nav').height() + 10, width: 'auto'}); } else if (scrollTop <= unitOffset) { unit.css({position: '', top: '', width: ''}); } }); } }); </xf:js>
Try this:How do I have to modify the code?
<xf:js>
var unit = document.querySelector('.samCodeUnit[data-position="container_sidebar_below"]');
if (unit) {
var unitOffset = unit.getBoundingClientRect().top + window.scrollY;
window.addEventListener('scroll', function() {
var unitScrollOffset = unit.getBoundingClientRect().top + window.scrollY;
var scrollTop = window.scrollY;
if (unitScrollOffset - scrollTop <= 0) {
unit.style.position = 'fixed';
unit.style.top = document.querySelector('.p-nav').offsetHeight + 10 + 'px';
unit.style.width = 'auto';
} else if (scrollTop <= unitOffset) {
unit.style.position = '';
unit.style.top = '';
unit.style.width = '';
}
});
}
</xf:js>
Perfect, thank you!Try this
I have several banners (A, B, C) for the same location say header. Each banner has the same views count say 10k a month.Set them up as 2 different banners, each will have its own stats.
A banner ad can have more than one banner uploaded. Click stats will show clicks on both.Is there any way we can do A/B testing for a banner?
How do I have to modify the code so that it is ignored on mobile phone? The ad should not be sticky there.JavaScript:<xf:js> var unit = document.querySelector('.samCodeUnit[data-position="container_sidebar_below"]'); if (unit) { var unitOffset = unit.getBoundingClientRect().top + window.scrollY; window.addEventListener('scroll', function() { var unitScrollOffset = unit.getBoundingClientRect().top + window.scrollY; var scrollTop = window.scrollY; if (unitScrollOffset - scrollTop <= 0) { unit.style.position = 'fixed'; unit.style.top = document.querySelector('.p-nav').offsetHeight + 10 + 'px'; unit.style.width = 'auto'; } else if (scrollTop <= unitOffset) { unit.style.position = ''; unit.style.top = ''; unit.style.width = ''; } }); } </xf:js>
Try:How do I have to modify the code so that it is ignored on mobile phone?
<xf:js>
var unit = document.querySelector('.samCodeUnit[data-position="container_sidebar_below"]');
if (unit && !/Mobi|Android/i.test(navigator.userAgent)) {
var unitOffset = unit.getBoundingClientRect().top + window.scrollY;
window.addEventListener('scroll', function() {
var unitScrollOffset = unit.getBoundingClientRect().top + window.scrollY;
var scrollTop = window.scrollY;
if (unitScrollOffset - scrollTop <= 0) {
unit.style.position = 'fixed';
unit.style.top = document.querySelector('.p-nav').offsetHeight + 10 + 'px';
unit.style.width = 'auto';
} else if (scrollTop <= unitOffset) {
unit.style.position = '';
unit.style.top = '';
unit.style.width = '';
}
});
}
</xf:js>
Fixed an issue with CSV export and pagination.
This doesn't seem to be working properly. I can no longer see the ad on my mobile phone (iPhone).Try:
That's strange. Maybe it's because of Google AdSense that the ad isn't displayed on mobile?The code provided doesn't do anything to ad display.
We use essential cookies to make this site work, and optional cookies to enhance your experience.