@@ -191,7 +191,17 @@ class Bling extends Component {
191
191
*
192
192
* @property style
193
193
*/
194
- style : PropTypes . object
194
+ style : PropTypes . object ,
195
+ /**
196
+ * An optional property to control non-personalized Ads.
197
+ * https://support.google.com/admanager/answer/7678538
198
+ *
199
+ * Set to `true` to mark the ad request as NPA, and to `false` for ad requests that are eligible for personalized ads
200
+ * It is `false` by default, according to Google's definition.
201
+ *
202
+ * @property npa
203
+ */
204
+ npa : PropTypes . bool
195
205
} ;
196
206
197
207
/**
@@ -217,7 +227,13 @@ class Bling extends Component {
217
227
* @property reRenderProps
218
228
* @static
219
229
*/
220
- static reRenderProps = [ "adUnitPath" , "slotSize" , "outOfPage" , "content" ] ;
230
+ static reRenderProps = [
231
+ "adUnitPath" ,
232
+ "slotSize" ,
233
+ "outOfPage" ,
234
+ "content" ,
235
+ "npa"
236
+ ] ;
221
237
/**
222
238
* An instance of ad manager.
223
239
*
@@ -387,8 +403,9 @@ class Bling extends Component {
387
403
}
388
404
389
405
componentWillReceiveProps ( nextProps ) {
390
- const { propsEqual } = Bling . _config ;
391
- const { sizeMapping } = this . props ;
406
+ const { propsEqual} = Bling . _config ;
407
+ const { sizeMapping} = this . props ;
408
+
392
409
if (
393
410
( nextProps . sizeMapping || sizeMapping ) &&
394
411
! propsEqual ( nextProps . sizeMapping , sizeMapping )
@@ -601,10 +618,12 @@ class Bling extends Component {
601
618
}
602
619
603
620
defineSlot ( ) {
604
- const { adUnitPath, outOfPage } = this . props ;
621
+ const { adUnitPath, outOfPage, npa } = this . props ;
605
622
const divId = this . _divId ;
606
623
const slotSize = this . getSlotSize ( ) ;
607
624
625
+ this . handleSetNpaFlag ( npa ) ;
626
+
608
627
if ( ! this . _adSlot ) {
609
628
if ( outOfPage ) {
610
629
this . _adSlot = Bling . _adManager . googletag . defineOutOfPageSlot (
@@ -779,6 +798,24 @@ class Bling extends Component {
779
798
780
799
return < div id = { this . _divId } style = { style } /> ;
781
800
}
801
+
802
+ /**
803
+ * Call pubads and set the non-personalized Ads flag, if it is not undefined.
804
+ *
805
+ * @param {boolean } npa
806
+ */
807
+ handleSetNpaFlag ( npa ) {
808
+ if ( npa === undefined ) {
809
+ return ;
810
+ }
811
+
812
+ Bling . _adManager . pubadsProxy ( {
813
+ method : "setRequestNonPersonalizedAds" ,
814
+ args : [ npa ? 1 : 0 ] ,
815
+ resolve : null ,
816
+ reject : null
817
+ } ) ;
818
+ }
782
819
}
783
820
784
821
// proxy pubads API through Bling
0 commit comments