atwwei / ngx-dfp

Semantic DoubleClick for Publishers (DFP by Google) integration with Angular v6.0.
16 stars 15 forks source link

Reload config based on user cookie preference #45

Closed newcreativegamer closed 4 years ago

newcreativegamer commented 4 years ago

Hi,

I would greatly appreciate fast feedback on this one. I want to change the personalizedAds from true to false at runtime when the user accepts tracking cookies. What is the best way of changing the config at runtime?

Thanks, Alan.

atwwei commented 4 years ago

@newcreativegamer You can try to change the configuration using googletag.cmd as follows:

googletag.cmd.push(() => {
    // Mark ad requests to request non-personalized ads.
    googletag.pubads().setRequestNonPersonalizedAds(1);
    // Refresh ads when necessary
    googletag.pubads().refresh();
});
newcreativegamer commented 4 years ago

Thanks @atwwei! That's exactly what I was looking for.