Angular GPT
A Angular implementation of the google GPT API.
Installation:
To install just run the following command (no other dependencies are required):
npm install --save ng-gpt
or
yarn add ng-gpt
Implementation
import { GptModule } from 'ng-gpt';
...
@NgModule({
declarations: [AppComponent],
imports: [
GptModule.forRoot({
idleLoad: true,
enableVideoAds: true,
personalizedAds: false,
singleRequestMode: false,
cookies: false,
ppid: '',
centering: true,
onSameNavigation: 'refresh',
globalTargeting: {
food: ['chicken', 'meatballs'],
},
enableLazyLoad: {
fetchMarginPercent: 500,
renderMarginPercent: 200,
mobileScaling: 2.0,
},
}),
],
providers: [],
bootstrap: [AppComponent],
})
<gpt-ad
id="1625556673407-0"
adUnit="/35096353/pub-showcase"
[sizes]="[[728, 90]]"
[sizeMapping]="[
{ viewport: [1024, 768], sizes: [[728, 90],[300, 250]] },
{ viewport: [900, 768], sizes: [[300, 250],[210, 60]] }
]"
[targetingArguments]="{ categories: ['restaurantes', 'abogados'] }"
[collapseEmptyDivs]="true"
></gpt-ad>
Parameters
adUnit
[string
] - required Full ad unit path with the network code and unit code.id
[string
] - ID of the div that will contain this ad unit.size
[[number, number][] | string
] - Width and height of the added slot. This is the size that is used in the ad request if no responsive size mapping is provided or the size of the viewport is smaller than the smallest size provided in the mapping. Default fluid
.sizeMapping
[{viewport: [number, number]; sizes: [number, number][]}[]
] - Array of size mappings. Each size mapping is an array of two elements.forceSafeFrame
[boolean
] - true to force all ads in this slot to be rendered in SafeFrames and false to opt-out of a page-level setting (if present). Setting this to false when not specified at page-level, won't change anything.safeFrameConfig
[string
] - slot-level preferences for SafeFrame configuration. Any unrecognized keys in the config object will be ignored. The entire config will be ignored if an invalid value is passed for a recognized key.refresh
[number
] - refresh interval.collapseEmptyDivs
[boolean
] - Sets whether the slot div should be hidden when there is no ad in the slot.targetingArguments
[[key: string]: any
] - custom targeting parameters for a given key that apply to all pubads service ad slots.