Comments (13)
If you want to serve non-personalized ads to all users, the easiest way would be to use the DFP settings (https://support.google.com/dfp_premium/answer/7673898). By default, DFP will send personalized ads to non-European-Economic-Area users.
We don't currently have a way to do googletag.pubads().setRequestNonPersonalizedAds(1)
for all readers using this plugin. It may be possible to enqueue JavaScript from your theme to access the googletag
variable that DFP uses.
from doubleclick-for-wp.
Any idea what would be the best way to do this? I've tried:
<script> googletag.cmd.push( function() { googletag.pubads().setRequestNonPersonalizedAds(1); googletag.enableServices(); }); </script>
Without any luck. Only managed to get it working once by enqueueing a custom version of jquery.dfp.js but that threw a lot of JS errors.
from doubleclick-for-wp.
I would write something like this:
<script>
window.googletag.pubads().setRequestNonPersonalizedAds(1);
</script>
And then wrap it in a PHP function, and add_action that function with priority 9 on wp_print_footer_scripts
in order to get there before DoubleClick::footer_script
But that doesn't affect already-fetched ads, and might not trigger before the JS in DoubleClick::footer_script
, so you may want to use disableInitialLoad
, make the change, and then refresh()
.
I haven't tried this yet, but what you could attempt is setting disableInitialLoad
via an argument on the jQuery( 'selector' ).dfp({})
call. Unfortunately there aren't any ways to do that without dequeueing DFW's code and enqueueing your own. You'd want to adjust the footer script:
doubleclick-for-wp/dfw-init.php
Lines 187 to 204 in d90fba3
And in the lazy-loader in jquery.dfw.js:
doubleclick-for-wp/js/jquery.dfw.js
Lines 32 to 39 in ac6a821
An ideal revision to this plugin would be to set a filter on $data
here:
doubleclick-for-wp/dfw-init.php
Lines 159 to 166 in d90fba3
And then, once the filtered options are output via the script localization on the page as the global dfw
variable, have the footer script draw from dfw
instead of using its own hardcoded options here:
doubleclick-for-wp/dfw-init.php
Lines 187 to 204 in d90fba3
Then as an example of how to use this, we'd need some docs about using window.googletag.pubads().refresh()
to summon new ads once it's appropriate to load, and an example short plugin to put that in a popup to show how this might be used in a "can we load personalized ads y/n?" example, with the PHP filter and the js for the popup.
In conclusion, you're right, you'd need to customize this plugin some, but here's the list:
- make a filter on
$data
before it's localised by callingapply_filters()
on it - figure out how to get
jquery.dfw.js
to load arbitrary options from thedfw
option, same as the footer script. What would probably work here is getting the keys on$data
to be the appropriate keys for use as the configuration options thatjQuery.dfp
is looking for. - refactor
DoubleClick::footer_script
to draw fromwindow.dfw
instead of its own options
Please, if you have any questions about this response, let me know. This response not very well-edited and may be missing some code.
from doubleclick-for-wp.
How about dequeueing the minified JS, enqueuing the non-minified JS and adding the setRequestNonPersonalizedAds(1) straight into the code (as a quick fix since i'm not making any progress).
from doubleclick-for-wp.
Yep, you could do that, and that does sound pretty easy.
from doubleclick-for-wp.
No luck!
Any chance of making this an update for all of us EU based users of this plugin?
from doubleclick-for-wp.
We'll add it to the next milestone for this plugin, but I can't guarantee a release date for that fix.
Can you upload your edited version of the non-minified JS, please? Seeing what didn't work may help us get an update out faster.
from doubleclick-for-wp.
I added:
pubadsService.setRequestNonPersonalizedAds(1);
Beneath:
if (dfpOptions.noFetch) { pubadsService.noFetch(); }
On line 297.
Ideal would be to have some kind of filter/hook that we can access, for example using our cookie consent script.
from doubleclick-for-wp.
Thanks for providing the edit.
What cookie consent script are you using?
from doubleclick-for-wp.
It's a custom one based one, pretty straight forward. I've created a simple WordPress function that checks if consent is given. Ideal for showing/hiding ads. That's why a filter/hook would be awesome!
from doubleclick-for-wp.
Any progress in adding this? Thanks!
from doubleclick-for-wp.
@tienvooracht Progress is starting in #81 and would be merged in the next 24 hours. What sorts of documentation would be helpful to you in using the filter added here? https://github.com/INN/doubleclick-for-wp/pull/81/files#diff-d3aa22c88317ac877d6ef91e82d40c08R172
from doubleclick-for-wp.
#81 is merged for 0.3.
@tienvooracht please let us know if the filter 'dfw_js_data'
added in #81 works for you; I'm closing this issue for now but we can reopen it.
from doubleclick-for-wp.
Related Issues (20)
- Support Google's CCPA framework
- Update to jquery.dfp.js 2.4.2
- Can the plugin be adapted to support exchange/header bidding?
- DoubleClick is renaming to Google Ad Manager HOT 3
- Gutenberg support? HOT 1
- ads.txt support?
- If a site's breakpoints change, the widgets break.
- standardize on max_width or max-width
- save plugin version number in database, and lay groundwork for upgrade framework
- Tag 0.3 HOT 2
- Programmatic insertion of SCAMP blocks HOT 1
- Review WordPress.org support forums HOT 1
- No google ad manager ads appearing anywhere on website HOT 8
- random log dump; needs triage HOT 1
- Another report of ads not fetching HOT 3
- Review all places where jquery.dfp.js and jquery.dfp.min.js are referenced
- The not-lazy-load ad loader needs to wait until jQuery.dfp is available
- non-lazyload ads are being loaded with incomplete options settings, and the mapping object's ad_sizes array is misformatted
- lazyload init js is output on wp-login.php
- Iframe won't render when the div rendered via ajax (load more data) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doubleclick-for-wp.