Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:01:11+00:00 2026-06-11T04:01:11+00:00

I am currently using google publisher tags with DFP to serve up ads to

  • 0

I am currently using google publisher tags with DFP to serve up ads to a site that will very soon be responsive. We have one particular ad slot which can potentially serve up 2 potential widths, 728 or 960 and depending on which width gets served up I want to either render the ad above or below the nav.

So the obvious first question is whether or not this is even remotely sane and furthermore is it possible? I suspect i should probably define two distinct ad slots.

The primary question though which is probably more of an academic one is how can I detect the dimensions of an ad that has been served? I suspect the solution to this is agnostic to the ad platform since I am basically detected node insertion and then inspecting the dimensions of the container element.

I’ve been experimenting with the DOMNodeInserted javascript event however it seems to trigger for everything “BUT” the ads. I am confused by this unless gpt inserts the ads in a way that does not trigger this event.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:01:13+00:00Added an answer on June 11, 2026 at 4:01 am

    I have done something like this before… and the method I settled upon was overriding an internal DFP function (renderEnded) so that I could see what the ad was at the point it had rendered on screen…

    For example to get the dimensions of the ad you could do something like the following (I’ve only tested this in chrome but it shouldn’t be too far from being fully cross browser):

    <html>
    <head>
        <title>DFP test</title>
    
        <script type='text/javascript'>
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            (function() {
                var gads = document.createElement('script');
                gads.async = true;
                gads.type = 'text/javascript';
                var useSSL = 'https:' == document.location.protocol;
                gads.src = (useSSL ? 'https:' : 'http:') +
                '//www.googletagservices.com/tag/js/gpt.js';
                var node = document.getElementsByTagName('script')[0];
                node.parentNode.insertBefore(gads, node);
            })();
        </script>
    
    
        <script type="text/javascript">
            googletag.cmd.push(function() {
                var slot1 = googletag.defineSlot('/12345678/TEST', [266, 115], 'div-gpt-ad-1340819095858-0').addService(googletag.pubads());
    
                slot1.oldRenderEnded = slot1.renderEnded;
                slot1.renderEnded = function(){
                    window.console.log('width: '+document.getElementById('div-gpt-ad-1340819095858-0').getElementsByTagName('iframe')[0].contentWindow.document.width);
                    window.console.log('height: '+document.getElementById('div-gpt-ad-1340819095858-0').getElementsByTagName('iframe')[0].contentWindow.document.height);
                    slot1.oldRenderEnded();
                };
    
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
        </script>
    
    </head>
    <body>
    
        <div id='div-gpt-ad-1340819095858-0' style='width:266px; height:115px;'>
            <script type='text/javascript'>
                googletag.cmd.push(function() {
                    googletag.display('div-gpt-ad-1340819095858-0');
                });
            </script>
        </div>
    
    </body>
    </html>
    

    That might not be quite what you are after but overriding that function should let you get to where you need to be… let me know if you have any questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a site that is using Google Checkout's mini cart system and
I have created a simple python web site using Google App Engine. Currently, the
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
I currently have a client website on the Grid server on MediaTemple that will
I have searched the Selenium Webdriver APi docs hosted on google code. Currently using
I'm currently using OAuth 2.0 to access Google's reader API. I have successfully gotten
I am currently using Google AppEngine(Java) to build a web site. I created a
Im currently developing a project using Google Maps. The whole function that im stucked
I am currently using Django forms with the Google App Engine and I have
I have an application which is currently using the google map API. I like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.