@fnet/gpt-slot-ext

0.1.5 • Public • Published

@fnet/gpt-slot-ext

This project provides a straightforward method to create and manage ad slots for Google Publisher Tags (GPT). It is designed to be a minimalistic approach to handling ad configurations, making it easier for developers to implement ad units within web applications.

How It Works

The project operates by allowing users to input ad configuration details such as the ad unit path, sizes, and targeting data. It then returns these details in a structured format. This enables developers to efficiently retrieve and incorporate ad slot configurations into their web applications with minimal setup.

Key Features

  • Ad Unit Configuration: Input and manage the adUnitPath, which specifies the unique path for the ad slot.
  • Size Management: Define the ad slot sizes to ensure they fit within your web application's layout.
  • Targeting Options: Set targeting parameters to control which ads are displayed based on user attributes or behavior.

Conclusion

@fnet/gpt-slot-ext provides a simple and clear approach to managing ad slot configurations for GPT. By focusing on the basic yet essential aspects of ad setup, it offers a streamlined solution for developers looking to integrate advertising into their platforms without complication.

Developer Guide for @fnet/gpt-slot-ext

Overview

The @fnet/gpt-slot-ext library is designed to simplify the management of ad slots in web applications. It allows developers to define ad units with specific configurations and retrieve these configurations easily for integration with advertising services. The library focuses on providing a straightforward API to handle ad unit paths, sizes, and targeting parameters efficiently.

Installation

You can install the @fnet/gpt-slot-ext library using npm or yarn. Follow the instructions below to include it in your project:

Using npm

npm install @fnet/gpt-slot-ext

Using yarn

yarn add @fnet/gpt-slot-ext

Usage

To utilize the @fnet/gpt-slot-ext library, you need to import the default export and use the provided functionalities to manage your ad slots. Here’s a basic example of how to define and retrieve an ad slot configuration:

import gptSlotExt from '@fnet/gpt-slot-ext';

const setupAdSlot = async () => {
  const adConfig = {
    adUnitPath: '/1234567/homepage',
    sizes: [[300, 250], [728, 90]],
    targeting: { interests: 'sports' },
  };

  const adSlot = await gptSlotExt(adConfig);
  const slotDetails = await adSlot.getSlot();

  console.log(slotDetails);
  // Output should look like: 
  // {
  //   adUnitPath: '/1234567/homepage',
  //   sizes: [[300, 250], [728, 90]],
  //   targeting: { interests: 'sports' }
  // }
};

setupAdSlot();

Examples

Here are some more examples demonstrating the core functionality of the library:

Example 1: Basic Ad Slot Configuration

import gptSlotExt from '@fnet/gpt-slot-ext';

const initAdSlot = async () => {
  const config = {
    adUnitPath: '/9876543/category',
    sizes: [[160, 600], [300, 600]],
    targeting: { audience: 'tech-savvy' },
  };

  const slot = await gptSlotExt(config);
  const details = await slot.getSlot();

  console.log(details);
};

initAdSlot();

Example 2: Multiple Sizes and Multiple Targeting Keys

import gptSlotExt from '@fnet/gpt-slot-ext';

const configureAdSlot = async () => {
  const multiConfig = {
    adUnitPath: '/3456789/articles',
    sizes: [[320, 50], [300, 250], [728, 90]],
    targeting: { interests: 'gaming', ageGroup: '18-24' },
  };

  const slot = await gptSlotExt(multiConfig);
  const adDetails = await slot.getSlot();

  console.log(adDetails);
};

configureAdSlot();

Acknowledgement

This library was developed by Fnet and is maintained by its contributors. We appreciate any feedback or contributions to improve this project.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  adUnitPath:
    type: string
    description: Path of the ad unit
  sizes:
    type: array
    items:
      type: array
      items:
        type: integer
    description: Sizes for the ad unit as an array of integer arrays
  targeting:
    type: object
    additionalProperties:
      type: string
    description: Targeting parameters as key-value pairs
required:
  - adUnitPath
  - sizes
  - targeting

Readme

Keywords

none

Package Sidebar

Install

npm i @fnet/gpt-slot-ext

Weekly Downloads

0

Version

0.1.5

License

MIT

Unpacked Size

7.11 kB

Total Files

8

Last publish

Collaborators

  • serdark
  • serdar986
  • gboyraz