React DFP Documentation

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

 adSenseAttributes

The adSenseAttributes property is meant to configure a set of extra adSense keywords for your ads. This property is accepted by both components:

  1. DFPSlotsProvider
  2. AdSlot

You can find more information about this topic in the official gpt documentation:  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 dfpNetworkId="9999">
        <div className="desktop-ads">
          <AdSlot adSenseAttributes={{'page_url': 'example.com'}} sizes={[[728, 90], [300, 250]]} adUnit="homepage/1" />
        </div>
        <div className="mobile-ads">
          <AdSlot dfpNetworkId="1999" sizes={[[300, 250], [300, 600], 'fluid']} adUnit="homepage/mobile" />
        </div>
      </DFPSlotsProvider>
    );
  }
}

Notes:

  1. Lines 8: configure a global dfpNetworkId via <DFPSlotProvider>.
  2. Line 10: we define an ad-slot using the <AdSlot> component and configure the AdSense attribute 'page_url' using the property adSenseAttributes .
  3. Line 13: we define another ad slot, in this case the slot supports the following sizes: 300x250, 300x600 and 'fluid'.