Google ad manager - To check unit ID presence

0 votes
added May 22, 2020 in Google tools by lcjr First Warrant Officer (11,970 points)
// Google ads DOM commonly shows this
// <div id="div-gpt-ad-1554101456137-0" data-google-query-id="CO6djYjpxukCFWbocwEdA58FJg" style="display: none;">
// The trick to check the unit; when div id has css style of display: none and the existence HTML attribute of 'data-google-query-id'

$.fn.hasAttr = function(name) {  
    return this.attr(name) !== undefined;

  if(($(dfpStoFullId).css('display') == 'none') || !$(dfpStoFullId).hasAttr('data-google-query-id')){ 
    console.log('sto display none');
  } - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.