GPTProvider
The GPTProvider
needs to be defined in order for ad units to load. Ideally it should be defined on a per-page basis, and as low down the component tree as possible.
import { GPTProvider } from 'goopubtag';
const MyPage = () => {
return (
<GPTProvider networkId={123456} debug={true}>
<MyComponent />
</GPTProvider>
);
};
export default MyPage;
Props
Here is a complete list of props available for GPTProvider
, with details of each below:
Prop | Type | Required |
---|---|---|
networkId | number | β |
children | ReactNode | β |
debug | boolean | β |
personalizedAds | boolean | β |
singleRequest | boolean | β |
disableInitialLoad | boolean | β |
limitedAds | boolean | β |
autoLoad | boolean | β |
lazyLoad | boolean | LazyLoad | β |
autoReload | AutoReload | β |
fallback | Collapse | β |
outOfPage | OutOfPage | β |
adUnit | string | β |
sizeMapping | SizeMapping[] | β |
adSenseAttributes | Attributes | β |
targetingArguments | Attributes | β |
It is important to note that some of the props can be overwritten at a slot level.
networkId
β
This is a unique identifier for the Ad Manager network the ad unit belongs to.
children
β
Children components are required and excluding will result in errors. It is useful to note that useGPT
cannot be used outside of the GPTProvider
, so best practice involves nesting your components one layer deep from where the context is declared.
debug
β
When enabled, a floating icon appears in the bottom right corner that when clicked opens the GPT console. Useful for development, should NOT be enabled in production.
personalizedAds
β
TBD
singleRequest
π·
When enabled, this will bundle requests for multiple ads into a single request.
disableInitialLoad
π·
TBD
limitedAds
β
When enabled, limited ads will be rendered for each ad slot defined.
autoLoad
π·
TBD
lazyLoad
β
Allows for lazy loading of ad units based on scroll position in viewport. See lazy load example.
autoReload
π·
TBD
fallback
β
This prop specifies the global collapseEmptyDivs
behaviour, and takes the following options:
default
: Acts the same as if prop is not providedexpand
: All ads will initially take no space, and each ad slot that gets filled will expand to fill its spacecollapse
: All ads will initally take space configured, and each slot that fails to fill will collapse to no size.
outOfPage
β
This prop determines the out of page behaviour, currently supporting the following types:
anchor
rewarded
The props are dynamic depending on the outOfPage type
set. To gain a better understanding, have a look at the following examples:
adUnit
β
This defines the parent-ad-unit-code at a top level for all contained ad slots.
sizeMapping
β
TBD
adSenseAttributes
β
TBD
targetingArguments
β
This prop is a simple key-value object that defines the page level targeting attributes for your GPT configuration.