React DFP Documentation

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

 configureSingleRequest

Use the method configureSingleRequest([boolean]) to manually select the strategy to trigger network requests.

  1. true : Enables Single Request Architecture (SRA).
  2. false : Use Multi-Request strategy. (default)

Important note: although this method will be always available and is meant for'public usage',
<DFPSlotProvider singleRequest /> 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.configureSingleRequest(true);
    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 enable the Single Request Architecture using the method:
    DFPManager.configureSingleRequest() and load the ads in this page using
    DFPManager.load([id])