React DFP Documentation

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

 personalizedAds

Use the prop personalizedAds to configure whether your page should receive personalized ads or not.

  1. - When true (default): ads personalization is enabled.
  2. - When false: personalization gets disabled.

Refer to the gpt documentation for more 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
import React, { Component } from 'react';
import { DFPSlotsProvider, AdSlot } from 'react-dfp';


export default class Example extends Component {
  render() {
    return (
      <DFPSlotsProvider personalizedAds={false} dfpNetworkId="9999">
        <div className="desktop-ads">
          <AdSlot sizes={[[728, 90], [300, 250]]} adUnit="homepage/1" />
        </div>
        <div className="mobile-ads">
          <AdSlot sizes={[[320, 50], [300, 50]]} adUnit="homepage/mobile" />
        </div>
      </DFPSlotsProvider>
    );
  }
}

Notes:

  1. Line 8 configure default / global properties using the<DFPSlotProvider>. We use the property personalizedAds to disable ads personalization.
  2. Line 10: define an ad-slot using the <AdSlot> component.
  3. Line 13: define another ad-slot using the <AdSlot> component.