@bygd/opus-gpt-slot-hl
v0.1.24
Published
## Introduction
Downloads
62
Readme
@bygd/opus-gpt-slot-hl
Introduction
The @bygd/opus-gpt-slot-hl
project provides a utility for configuring and managing advertising slots on web pages. It simplifies the task of setting up ad slots by automatically fetching and applying configuration details, making it easier for developers to prepare their web pages for ad delivery.
How It Works
This project functions by accessing configuration data specific to your page and ad requirements. By interfacing with external configuration tools, it retrieves necessary data about ad slots such as targeting criteria, sizes, and paths. Once this data is obtained, it processes and prepares ad units for your use, allowing for seamless integration with advertisement delivery networks.
Key Features
- Automated Configuration Retrieval: Automatically gathers required configuration from a specified source, reducing manual setup.
- Ad Slot Management: Facilitates creating ad slots with appropriate sizes and path specifications.
- Customizable Targeting: Allows additional targeting specifications to be added or modified, offering flexibility in how ads are targeted.
Conclusion
In essence, @bygd/opus-gpt-slot-hl
aids in the efficient setup and management of ad slots on web pages by leveraging pre-configured settings and providing the necessary data structure required to implement ads. It focuses on simplifying the process for web developers, allowing them to concentrate more on content development and user experience.
Developer Guide for @bygd/opus-gpt-slot-hl
Overview
The @bygd/opus-gpt-slot-hl
library is designed to streamline the process of configuring ad slots with Google's Publisher Tags (GPT). By utilizing this library, developers can easily configure and generate ad unit paths, sizes, and targeting parameters for ad slots. The core functionality revolves around retrieving and managing slot configuration efficiently.
Installation
Install the library using npm or yarn. This will set up the required package and handle any dependencies automatically.
npm
npm install @bygd/opus-gpt-slot-hl
yarn
yarn add @bygd/opus-gpt-slot-hl
Usage
To use the library, import the library and utilize the primary exported function to obtain and configure ad slots. The function primarily relies on the hl_config
parameter, which can be auto-fetched or provided directly.
Example
Here's a basic example demonstrating how to use the library to configure an ad slot:
import getSlotConfig from '@bygd/opus-gpt-slot-hl';
async function configureAdSlot() {
// Define the parameters for the ad slot
const parameters = {
page_url: 'https://example.com',
page_type: 'article',
asset_id: '123456',
slot_id: 'header-banner',
sizes: [[728, 90]], // Custom size for the ad slot
targeting: {
age: '30-40',
interest: 'technology'
}
};
// Get slot configuration function
const { getSlot } = await getSlotConfig(parameters);
// Retrieve the ad slot configuration
const slotConfig = await getSlot();
console.log(slotConfig);
// {
// adUnitPath: '/networkCode/adUnitCode',
// sizes: [[728, 90]],
// targeting: { age: '30-40', interest: 'technology', existingKey: 'existingValue' }
// }
}
configureAdSlot();
Examples
Basic Slot Configuration
Configure an ad slot with custom parameters:
import getSlotConfig from '@bygd/opus-gpt-slot-hl';
async function loadAd() {
const parameters = {
page_url: 'https://example.com',
slot_id: 'sidebar',
sizes: [[300, 250]]
};
const { getSlot } = await getSlotConfig(parameters);
const slotConfig = await getSlot();
console.log('Ad Unit Path:', slotConfig.adUnitPath);
console.log('Ad Sizes:', slotConfig.sizes);
console.log('Targeting:', slotConfig.targeting);
}
loadAd();
Using Default Slot Sizes and Targeting
Skip defining sizes
and let the library use default configurations from hl_config
:
import getSlotConfig from '@bygd/opus-gpt-slot-hl';
async function loadDefaultAd() {
const parameters = {
page_url: 'https://example.com',
slot_id: 'footer'
};
const { getSlot } = await getSlotConfig(parameters);
const slotConfig = await getSlot();
console.log('Ad Unit Path:', slotConfig.adUnitPath);
}
loadDefaultAd();
Acknowledgement
This guide leverages Google's GPT API for ad slot configurations. Special thanks to contributors and collaborators involved in the development and maintenance of this library.
Input Schema
$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
hl_config:
description: Configuration object for high-level settings.
type: object
page_url:
description: The URL of the page where the ad will be displayed.
type: string
page_type:
description: The type of the page, used in fetching configuration.
type: string
asset_id:
description: Identifier for the asset associated with the page.
type: string
slot_id:
description: Identifier for the ad slot.
type: string
sizes:
description: Dimensions for the ad slot.
type: array
items:
type: array
items:
type: integer
targeting:
description: Key-value targeting for ads, used for additional ad configurations.
type: object
additionalProperties:
type: string
required:
- page_url
- page_type
- asset_id
- slot_id