React DFP Documentation

  ·  Build Status Npm Downloads Minizipped size GitHub license Dependencies
Minizipped size

 configurePersonalizedAds

Use the method configurePersonalizedAds([boolean]) to manually configure the stragy to follow to serve ads:

  1. true : Serve personalized ads (via cookie/tracking).
  2. false : Do not serve personalized ads.

Important note: although this method will be always available and is meant for 'public usage',
<DFPSlotProvider personalizedAds /> is the recomended way to approach this behavior, please use that one one if possible.

See google gpt docs for details:  link

Example:

ADS GO HERE...

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import React, { Component } from 'react';
import { AdSlot, DFPManager } from 'react-dfp';


export default class Example extends Component {
  componentDidMount() {
    DFPManager.configurePersonalizedAds(false);
    DFPManager.load();
  }

  render() {
    return (
      <div>
        <div className="desktop-ads">
          <AdSlot slotId="test1" dfpNetworkId="9999" sizes={[[728, 90], [300, 250]]} adUnit="homepage/1" />
        </div>
        <div className="mobile-ads">
          <AdSlot slotId="test2" dfpNetworkId="9999" sizes={[[320, 50], [300, 50]]} adUnit="homepage/mobile" />
        </div>
      </div>
    );
  }
}

Notes:

  1. Lines 15,18: we define two ad slots using the <AdSlot>component.
  2. Lines 7-8: we manually disable any ads personalization usin the method:
    DFPManager.configurePersonalizedAds(false) and load the ads in this page using
    DFPManager.load([id])