• Resolved tricknshop1

    (@tricknshop1)


    Ad Inserter has been very useful plugin for inserting various ads on our website. I am facing issue while inserting an Ad Unit on Post pages using Ad Inserter in Infinite Scroll. I am using Ad inserter to insert Google Ad Manager Ad Units on article pages, everything works fine except the ad unit does not show on next article while the infinite scroll active.

    It is the same ad unit as in Normal Article which works absolutely fine but when it is called inside the next article of Infinite Scroll it just don’t show. I think it is due to having same Div id for both units as in First Article and in the next article of infinite scroll.

    The solution can be changing the Ad Unit Div id Article dynamically. Can you help me achieve this and provide a solution to change div id dynamically. If you have some better idea which can work to resolve the problem please let me know.

    Ad Unit Showing Ad in First Post

    Same Ad Unit Not Showing Ad in Next Post in Infinite Scroll

    The Ad Unit Code is:

    <div id='div-ad-gpt-21619024108-1677680703-0'></div>
    <script>
    	window.googletag = window.googletag || {cmd: []};
    	googletag.cmd.push(function() {
    		var aff_w = window.innerWidth;
    
    
    		if (aff_w >= 728) {
    	
    			googletag.defineSlot('/21619024108/Nayag_Desktop_AP_MID1_728x90', [[728, 90]], 'div-ad-gpt-21619024108-1677680703-0').addService(googletag.pubads());
    
    			document.getElementById('div-ad-gpt-21619024108-1677680703-0').style.minHeight = 90+"px";
    			googletag.enableServices();
    			googletag.display('div-ad-gpt-21619024108-1677680703-0');
    	
    		}   else {
    			googletag.defineSlot('/21619024108/Nayag_Mobile_AP_MID1_336x280', [[300, 250], [336, 280]], 'div-ad-gpt-21619024108-1677680703-0').addService(googletag.pubads());
    
    			googletag.enableServices();
    			document.getElementById('div-ad-gpt-21619024108-1677680703-0').style.minHeight = 280+"px";
    			googletag.display('div-ad-gpt-21619024108-1677680703-0');
    		} 
    	
    
    	});
    </script>

    I am implementing it on test site you can check it here at

    Thanks

    • This topic was modified 3 years, 3 months ago by tricknshop1.
    • This topic was modified 3 years, 3 months ago by James Huff. Reason: link moved to proper field

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Spacetime

    (@spacetime)

    You are right, IDs need to be unique on the page. For multiple insertions on the same post you can use this approach:
    https://adinserter.pro/documentation/ad-manager-ads#multiple-ads

    However, for multiple posts there is no way for the plugin to distinguish the additional posts loaded via ajax requests from the first loaded post. Mainly this depends on the plugin or theme doing the infinite scroll. If you can somehow pass this information to the plugin (e.g. via url parameters) then I can try to suggest possible approaches to make IDs unique.

Viewing 1 replies (of 1 total)

The topic ‘Changing Ad Unit Div id Dynamically for GAM’ is closed to new replies.