Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another report of ads not fetching #92

Open
benlk opened this issue Jan 2, 2019 · 3 comments
Open

Another report of ads not fetching #92

benlk opened this issue Jan 2, 2019 · 3 comments
Labels
Milestone

Comments

@benlk
Copy link
Collaborator

benlk commented Jan 2, 2019

From https://secure.helpscout.net/conversation/739589544/2981/?folderId=1219602

WP 5.0.2
PHP 7.2.2
Plugins:

It's a long list
  • Advanced Cron Manager
  • Advanced Custom Fields PRO
  • Akismet Anti-Spam
  • Alexa Certify
  • All In One SEO Pack
  • AMP
  • Beautiful taxonomy filter
  • Better WordPress Recent Comments
  • BP Profile Search
  • BuddyPress
  • BuddyPress Friends Only Activity Stream
  • Buddypress Messages Spam Blocker
  • BuddyPress Xprofile Custom Fields Type
  • Classic Editor
  • Cloudflare
  • Co-Authors
  • Comments Like Dislike
  • Cookie Consent
  • DoubleClick for WordPress
  • Edit Flow
  • Email Address Encoder
  • Enhanced Text Widget
  • Export Users to CSV
  • Featured Images in RSS w/ Size and Position
  • Gravity Forms
  • Gravity Forms Polls Add-On
  • Gravity Forms Quiz Add-On
  • iframe
  • Jetpack by WordPress.com
  • Lazy Load for Comments
  • MemberPress Business Edition
  • MemberPress
  • MailChimp
  • MetaSlider
  • oEmbed in Comments
  • PHP Compatibility Checker
  • Popup Maker
  • Post-Plugin Library
  • Public Post Preview
  • Recent Posts Widget Extended
  • Redis Object Cache
  • Regenerate Thumbnails
  • Register IPs
  • Revision Control
  • Simple 301 Redirects
  • Simple Image Widget
  • Simple Lightbox
  • Stop New User + Change Password Emails Select
  • Stop Spammers
  • Theme Check
  • Upcoming Events
  • Widget Select
  • VaultPress Widget CSS Classes
  • Wordfence Security
  • Wordpress Video Plugin
  • WP Crontrol
  • WP Missed Schedule
  • WP Resized Image Quality
  • WP ULike
  • WP-Ban
  • WP-Cron Status Checker
  • Yet Another Related Posts Plugin

some of those are plugins I wrote myself, if they look unfamiliar

Custom theme
Plugin version 0.3

The contents of the ?googfc error:

  1. That's an error. The requested URL was not found on this server. That's all we know.
    The "slot size" shows the height as zero though.

Other details:

Our ad folks said the reason the ads are no longer displaying is that the sizes are now being sent incorrectly:

The issue why you are getting a 400 error here is that the request is sending incorrect ad size. In this example, it was sending these ad sizes :

  • 1115x0 for the leaderboard_top
  • 362x0 for the bigbox
  • 1115x0 for the leaderboard_bottom
@benlk benlk added the bug label Jan 2, 2019
@benlk
Copy link
Collaborator Author

benlk commented Jan 2, 2019

This may be related to #91 and #90.

Next steps:

  • compare with No google ad manager ads appearing anywhere on website #90 to see if the ad unit sizes are off
  • check to see if the variable renaming in 0.3 resulted in jquery.dfp.js attempting to get the height from an array key or object property that doesn't match the key/property that is actually in the thing.

@benlk benlk added this to the 0.3.1 milestone Jan 2, 2019
@benlk
Copy link
Collaborator Author

benlk commented Jan 29, 2019

But after updating the plugin, the site stopped showing ads and there were below errors in the console:

-> GET https://securepubads.g.doubleclick.net/gampad/ads?gdfp_req=1& .... with 400 error.
-> Access to XMLHttpRequest at 'https://securepubads.g.doubleclick.net/gampad/ads?gdfp_req=1&pvsid=417413281066130& ........' from origin 'https://example.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

After digging up in the code, I found below DOM code in the footer of the website:

plugin ver 0.3 code:

jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp( window.dfw );

which is different than the earlier version of the plugin which is as below:

plugin ver 0.2.1 code:

jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp({
    dfpID: '<?php echo $this->networkCode(); ?>',
    collapseEmptyDivs: false,
    setTargeting: <?php echo json_encode($this->targeting()); ?>,
    sizeMapping: <?php echo json_encode($mappings); ?>
});

The older plugin was using these php values instead of the JS var dfw.

So, I commented out the below line in "/plugins/doubleclick-for-wp/inc/class-doubleclick.php" :

jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp( window.dfw );

and added this code:

jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp({
    dfpID: '<?php echo $this->network_code(); ?>',
    collapseEmptyDivs: false,
    setTargeting: <?php echo json_encode($this->targeting()); ?>,
    sizeMapping: <?php echo json_encode($mappings); ?>
});

which fixed the issue and I can see the ads on my site now and the category targeting also seem to be working.

  • is everything that should be drawing from window.dfw.dfpID drawing from dfpID and not something else?

@benlk
Copy link
Collaborator Author

benlk commented Jan 29, 2019

Aha.

$data = array(
'dfpID' => $this->network_code(),
'network_code' => $this->network_code(),
'mappings' => $mappings,
'targeting' => $this->targeting(),

window.dfw uses targeting and mappings; the added code uses setTargeting and sizeMapping.

  • Add those terms.

That might reduce the amount of code needed on

dfp_options = Object.assign( dfw, {
"collapseEmptyDivs": false,
"sizeMapping": dfw.mappings,
"setTargeting": dfw.targeting
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant