Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niksy/advertol-service-google-dfp
Google DFP/Ad Manager service.
https://github.com/niksy/advertol-service-google-dfp
Last synced: about 2 months ago
JSON representation
Google DFP/Ad Manager service.
- Host: GitHub
- URL: https://github.com/niksy/advertol-service-google-dfp
- Owner: niksy
- License: mit
- Created: 2019-04-01T14:39:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-14T11:14:21.000Z (over 1 year ago)
- Last Synced: 2024-10-18T03:48:45.832Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @advertol/service-google-dfp
[![Build Status][ci-img]][ci] [![BrowserStack Status][browserstack-img]][browserstack]
[Google DFP/Ad Manager](https://admanager.google.com/) service.
## Install
```sh
npm install @advertol/service-google-dfp --save
```## Usage
```html
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
```
```js
import advertol from '@advertol/core';
import GoogleDfpService from '@advertol/service-google-dfp';const instance = advertol({
// …
service: [
new GoogleDfpService({
zones: [{
id: 'becky',
adUnitPath: '/42/becky',
slot: () => window.googletag.defineSlot('/42/becky', ['fluid'], 'zone-becky').addService(window.googletag.pubads())
}]
})
]
});instance.resolve();
```## API
### googleDfpService({ zones, onSetup, refreshZones })
#### zones
Type: `Object[]`
List of zones with their slot callback.
| Property | Type | Description |
| --- | --- | --- |
| `slot` | `Function` | Function which returns [`googletag.defineSlot`][googletag-define-slot] or [`googletag.defineOutOfPageSlot`][googletag-define-outofpage-slot] instance. |
| `adUnitPath` | `string` | Full path of the ad unit with the network code and unit code. |
| `id` | `string` | Zone ID. |#### onSetup
Type: `Function`
Define additional initialization logic.
#### refreshZones(slots)
Type: `Function`
Refresh slots.
By default, it calls [`refresh`][googletag-refresh] method.
#### displayZone({element, id})
Type: `Function`
Display zone by ID.
By default, it calls [`display`][googletag-display] method.
##### slots
Type: `googletag.Slot[]`
List of slots to refresh.
### instance.addZone({ slot, adUnitPath, id })
Add new zone with slot callback.
| Property | Type | Description |
| --- | --- | --- |
| `slot` | `Function` | Function which returns [`googletag.defineSlot`][googletag-define-slot] or [`googletag.defineOutOfPageSlot`][googletag-define-outofpage-slot] instance. |
| `adUnitPath` | `string` | Full path of the ad unit with the network code and unit code. |
| `id` | `string` | Zone ID. |## Browser support
Tested in IE9+ and all modern browsers.
## Test
For automated tests, run `npm run test:automated` (append `:watch` for watcher support).
## License
MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://travis-ci.com/niksy/advertol-service-google-dfp
[ci-img]: https://travis-ci.com/niksy/advertol-service-google-dfp.svg?branch=master
[browserstack]: https://www.browserstack.com/
[browserstack-img]: https://www.browserstack.com/automate/badge.svg?badge_key=RENheEJRRGlDMGo3QWFhSTRoYy8wUHlwZFNPM2FhTHB3RUVDZzFGS0NaWT0tLXNheHBwbHpGcDJuMVB4Zjd1THlIUEE9PQ==--e54ee2f7777a7d1006c46c7a74113388d8e89ead
[googletag-define-slot]: https://developers.google.com/doubleclick-gpt/reference#googletag.defineSlot
[googletag-define-outofpage-slot]: https://developers.google.com/doubleclick-gpt/reference#googletag.defineOutOfPageSlot
[googletag-refresh]: https://developers.google.com/doubleclick-gpt/reference#googletag.PubAdsService_refresh
[googletag-display]: https://developers.google.com/doubleclick-gpt/reference#googletag.PubAdsService_display